Adobe Robohelp

Get new posts delivered straight to your inbox.

Subscriber count: 3,505

Stitcher radio

follow us in feedly

Want more tech comm blogs to follow? See my Tech Comm Collection of Blogs on Feedly.

Adobe Robohelp

Word Macro for Resizing Images that Have a Specific Style

Aug 9, 2008 • general

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), _
RelativeToOriginalSize:=msoCTrue
.ScaleWidth Factor:=(PercentSize / 100), _
RelativeToOriginalSize:=msoCTrue
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


Get new posts delivered straight to your inbox.

Subscriber count: 3,505

Powered by ZipRecruiter

About Tom Johnson

Tom Johnson

I'm a technical writer based in the California San Francisco Bay area. Topics I write about on this blog include technical writing, authoring and publishing tools, API documentation, tech comm trends, visual communication, technical writing career advice, information architecture and findability, developer documentation, and more. If you're a professional or aspiring technical writer, be sure to subscribe to email updates using the form above. You can learn more about me here.