Word: Resize Image by Percent - Macro

7

2

I routinely paste many screen captures into Microsoft Word 2007 and then have to manually resize them to around 75%, which becomes very tedious.

The screen captures are all different sizes.

I've tried creating a macro for this, but I'm only able to write a macro that will resize a selected image to specific dimensions. And I can't get the macro recorder to recognize either manually resizing in the document window or using the Size dialog.

Is it possible to write a macro that will resize a selected image to 75% of its current size?

This question is similar to mine, but the user's requirement is to resize all of his images to the same size. I need to resize images that have an arbitrary height/width.

I'm also open to a technique that will paste images at a smaller size to begin with.

cantera25

Posted 2011-12-20T20:35:48.997

Reputation: 173

Answers

8

Copy this code to a module in VBA Editor (Alt + F11) for your document. If there isn't a module already, you can select to add one from the insert menu.

    Sub PicResize()
     Dim PercentSize As Integer

     PercentSize = 75

     If Selection.InlineShapes.Count > 0 Then
         Selection.InlineShapes(1).ScaleHeight = PercentSize
         Selection.InlineShapes(1).ScaleWidth = PercentSize
     Else
         Selection.ShapeRange.ScaleHeight Factor:=(PercentSize / 100), _
           RelativeToOriginalSize:=msoCTrue
         Selection.ShapeRange.ScaleWidth Factor:=(PercentSize / 100), _
           RelativeToOriginalSize:=msoCTrue
     End If
 End Sub

To run a this macro press Alt + F8, select PicResize from the list of macros and click RUN. You can also assign it to a button in a menu, if you want to just click each time to run the macro.

CharlieRB

Posted 2011-12-20T20:35:48.997

Reputation: 21 303

Thanks for this, very helpful. There is a typo in your variable declaration on line 2 though, it missing the 'r' in 'PercentSize'. – moloko – 2017-11-11T00:28:59.567

Thanks. FYI, you can make edits as part of the function of this site. :-) – CharlieRB – 2017-11-11T01:52:29.923

Thanks CharlieRB - I appreciate the clear instructions. I almost have it working, but after executing the macro, Word becomes unstable -- I can no longer access anything from the Ribbon or close the program. Can you think of why this might be occurring? (I checked to make sure Windows XP / Office 2007 are fully updated.) Thanks! – cantera25 – 2011-12-21T19:27:25.797

1Not sure why that would happen. I had no problem running it multiple times on several images before I posted it for you. The code should be just fine for Office 2007. Might want to reboot and try again. – CharlieRB – 2011-12-21T20:06:49.690

Still having issues, but it's definitely something on my end. Accepted your answer - thanks again! This had been a problem for me for quite a while. – cantera25 – 2011-12-21T20:48:26.070

You're welcome. Glad to help. – CharlieRB – 2011-12-21T21:00:53.153

This macro just saved me hours of click-clicking. – Pierre Arnaud – 2014-02-20T05:43:55.737