Stay current with the latest in tech comm
Keep current with the latest trends in technical communication by subscribing to the I'd Rather Be Writing newsletter. 4,500+ subscribers

Stitcher radio

Search results

Word Macro for Resizing Images that Have a Specific Style

by Tom Johnson on Aug 9, 2008 • 0 Comments
categories: technical-writing

When you single source from an online help authoring tool and generate an output to Microsoft Word, almost invariably you have some clean-up reformatting to do. For me, one of these areas deals with screenshot images.

I prefer to have Word resize my screenshots (to a smaller size) because images look a lot sharper and crisper when Word resizes them rather than when SnagIt or Photoshop resizes them (even with smooth scaling selected).

Whatever your cleanup process, you might find the following image resizing macro helpful. It only resizes images that have a specific style (p_Result) before the image. It resizes the image to 75% of its original size.

Note: It's important to isolate images that are surrounded by a specific style because you don't want to resize all your images. You don't want your note, tip, caution, and button images shrunk to 75% of their original size. Also, your substep images may need to have smaller sizes than your regular image sizes.

Here's the macro:

Sub ImageResize()
Dim PercentSize As Integer
Dim MyStyle As String
Dim oIshp As InlineShape
Dim oshp As Shape
PercentSize = InputBox("Enter percent of full size", "ResizePicture ", 75)
MyStyle = "p_Result"
With ActiveDocument
For Each oIshp In .InlineShapes
With oIshp
If .Range.Paragraphs(1).Style = MyStyle Then
.ScaleHeight = PercentSize
.ScaleWidth = PercentSize
End If
End With
Next oIshp
For Each oshp In .Shapes
With oshp
If .Anchor.Paragraphs(1).Style = MyStyle Then
.ScaleHeight Factor:=(PercentSize / 100), _
.ScaleWidth Factor:=(PercentSize / 100), _
End If
End With
Next oshp
End With
End Sub

If you have no idea how to integrate a macro into your Word document, follow these steps. (This applies to Word 2007.)

  1. Click the Developer tab, and then click the Macros button.
  2. Type a name for the macro, such as ImageResize, and then click Create.
  3. Highlight the code that starts with Sub ImageResize and ends with End Sub.
  4. Paste the sample code above in its place, and then click Save and close the macro window.

To run the macro, first make sure your images have a p_Result style before them. Then do the following:

  1. Click the Developer tab, and then click the Macros button.
  2. Select the ImageResize macro, and click the Run button.
follow us in feedly