Monday, August 3, 2015

Macro to Resize Selected Image in Word 2013

While searching macros, one thing I've noticed is that some people tend to make macros more complicated than necessary. In my experience, the cleaner the code, the more efficient it runs. Granted, I am by no means an expert in creating macros. I have a lot to learn; however, I'm learning.


I recently needed a macro to resize a selected image to 75 percent of its original size. Unfortunately, the "Record Macro" feature was not working as expected, so off I went to Mister Google.


After searching several sites, I came across a solution, but needed to modify it a touch to make it work efficiently.  Here is the end result:


Sub Image_75_Percent()
'
' Resize the selected image to 75 percent of its original size.
'
    Dim PecentSize As Integer
    PercentSize = 75
    Selection.InlineShapes(1).ScaleHeight = PercentSize
    Selection.InlineShapes(1).ScaleWidth = PercentSize
   
   
End Sub


Copy and paste this into a new macro named "Image_75_Percent." Then select an image and run the macro. Since you scaled the height and width 75 percent, the aspect ratio will be maintained.


Cheers!
Christel

No comments:

Post a Comment