Bulk Image Resize in MS Word 2016

Steps Recorder is built in to Windows and is excelent for recording clicks when perfoming tasks on a PC. Saves the results to an .mht file too. Great … except … 300 images, 1366×2000-and-something plus 48MB causes an issue if you try opening in a browser. “OK, I’ll open it in Word”. Well, yeeessss … except …

… all the images initialise to 5x bigger than the page. All 300 of ‘em ! What we need is a macro to resize all images. Theres a few examples on-line but none worked correctly; either they blew up on documents containing a horizontal rule (Steps Recorder does indeed insert these) and the one example I found which checked it was an image blew up with an object null – which was nothing more than a missing “.” character.

So I don’t claim my script is original – just that I got it working for me :-) And here it is (if you hadn’t guessed, ScaleHeight and ScaleWidth are percent) :

Sub Resize()
    Dim i As Long
    With ActiveDocument
        For i = 1 To .InlineShapes.Count
        If .InlineShapes.Item(i).Type = _
wdInlineShapePicture Then
            With .InlineShapes(i)
                .ScaleHeight = 35
                .ScaleWidth = 35
            End With
            End If
        Next i
    End With
End Sub

(for VB newbs like me, the ‘_’ character is a new line marker.)

Of course the next barrier is this is Word 2016 so it took me a while to work out how to run a macro. Select [Developer] tab, you’ll find macros on the far left.



Leave a Reply