Creating a macro to resize the currently selected picture

B

Brian

I would like to create a macro that will resize the currently selected
picture to a pre-determined size. For example, we often past graphics that
contain charts. For appearance, we want all the charts to be uniform in size
(3.15" tall x 5" wide). I would also like to create a macro button where my
users can click the chart and just click the button to automatically resize
it. Having to right click on each picture and select properties, then the
size tab, then unchecking the Lock Aspect Ratio, then changing the size is
time consuming. One document will usually contain a minimum or 40-60 of
these pictures. Anybody know how to create this? Any help would be
appreciated.
 
L

Lene Fredborg

Below you will find a macro that resizes the selected picture to the size you
specified.

NOTE: If your pictures are not in the text layer (wrapping style "In line
with text" - set via Format > Picture > Layout tab) but floating (any other
wrapping style), you must change the code line "With
Selection.InlineShapes(1)" to the following:

With Selection.ShapeRange(1)

If no picture or a picture with a wrong wrapping style is selected, the
macro will display a message (change the wording of the message as you wish).

For information about assigning a macro to a toolbar, see:
http://word.mvps.org/FAQs/Customization/AsgnCmdOrMacroToToolbar.htm

-------------------------
The macro:

Sub ResizeSelectedPicture()

On Error GoTo ErrorHandler
With Selection.InlineShapes(1)
.LockAspectRatio = msoFalse
.Width = InchesToPoints(5)
.Height = InchesToPoints(3.15)
End With
Exit Sub

ErrorHandler:
MsgBox "Please select a picture with " & _
"wrapping style 'In line with text'. " & _
"Then retry."
End Sub

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top