Word Macro for Resizing Images that Have a Specific Style
August 9th, 2008 | Posted in Technical Writing 6 Comments »
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.)
- Click the Developer tab, and then click the Macros button.
- Type a name for the macro, such as ImageResize, and then click Create.
- Highlight the code that starts with Sub ImageResize and ends with End Sub.
- 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:
- Click the Developer tab, and then click the Macros button.
- Select the ImageResize macro, and click the Run button.
Tags: image resizing, macros, single sourcing, Word
Twitter
Facebook












Hi Tom
There’s no need to do this in Author-it. Author-it’s file objects allow you to set the Word resizing so it’s done automatically. In fact, there’s very little post-processing or checking in Author-it’s Word output, and you can get away with none. I still check for correct page breaks, but that’s all—and that’s a PERSONAL decision, not something I *have* to do. Even on a 400+ page document, checking the page breaks takes no more than 10-15 minutes. Then I PDF the document and it’s done.
Compared to other tools, Author-it’s Word output is ready to go, once you’ve set up your templates (a one-off process).
Rhonda
Rhondas last blog post..Transparent background for desktop icons
Rhonda, thanks for the note about AuthorIt. I decided to remove my reference to tools in the post entirely. I’ve always heard good things about AuthorIt, but once I did run into a guy who was an AuthorIt guru, and he said even he needed to apply about a dozen Word macros to the Word output to clean it up how he wanted. It probably just differs according to how complicated your Word formatting is.
Hi, Tom
I use several macros in my docs, but not to clean up formatting. In my master library, I use one that embeds images (by default, they’re linked when publishing to Word, and embedding means that I only have to send the Word doc and not the entire folder). I have another that adjusts the top spacing in Word options (because I don’t like the defaults). And I have one that clears the “Keep With Next” setting from all paragraphs with AllowPageBreak style to prevent page layout problems (AIT changes some of those paragraphs to use Keep with Next, mostly when they’re before graphics).
For some of my clients, I use more…turn on chapter numbering, modify page numbers to include chapter numbers, update the TOC to include appendices, and so on.
Formatting (other than the one mentioned above) never needs to be changed. Styles are defined in the template. Autotext entries provide the header and footer. Settings in AIT are passed to the Word doc to control if chapters/sections start on odd/even/next pages.
The nice thing about the macros is that once they’ve been added to the template, you just need to publish. Like Rhonda, all I ever do is fix page breaks.
The even nicer thing is that once all the bits have been set in AIT, they never have to be changed, and they can be used for any books (similar to “projects” in other applications). When I publish my training materials, I’m using things I first set up in 2001, and I have something like 100 books using those settings.
I’d be happy to give you a demo sometime
Char James-Tannys last blog post..FrameMaker support lists
Hi Tom
Like Char, I also use some macros in my Word docs, but these—like setting up the Word templates—are one-offs. Many Word things are already controlled by settings in Author-it, but there are a few macros I add to particular client templates if the need is there.
Char mentioned the embedding linked graphics one; I also use one to resize tables to fit the available width, another to ’swap out’ the table header colour to suit the ’skins’ of each of my client’s documentation outputs for their various customers, and so on. I’ve shared a couple of these macros on my blog: http://cybertext.wordpress.com/category/software/author-it-v5/
You can use Author-it’s default Word templates ‘out of the box’ and may never need to use a macro. You definitely don’t need one for resizing graphics, though I’ve worked at places where Word is the authoring tool of choice and would have killed for such a macro! Thanks for sharing.
Rhondas last blog post..World’s largest “how to” manual
Hi Tom
>sharper and crisper when Word resizes them rather than when SnagIt or Photoshop resizes them (even with smooth scaling selected).
Some photoshop tips – if you resize image more than 50% you must change size in few step and after each step use Unsharp Mask standard filter or use additional external resize plugin. If you need resize multiple images you can create Photoshop batch (Action).
[...] public links >> resizing Pixus – Pixel ruler on AIR Saved by nanaosaki101 on Fri 10-10-2008 Word Macro for Resizing Images that Have a Specific Style Saved by mileyfan009 on Thu 09-10-2008 Resizing Images On the internet – 6 Tips to Using an On [...]