How to resize all images to the same size in a Word Document with a single Click

if your Microsoft Word document contain multiple images, and you want to resize all the images to the same(specific) size, doing it manually image by image can be very time-consuming and tedious task. In this blog post, I am going explain how to resize all images to the same size in a word document with a single click using Macros and VBA code.

The Following Steps explain how to resize all pictures/shapes to the same size in a Word Document Using Macros and VBA Codes.

  1. Open the Visual Basic for Applications (VBA) editor or IDE by Pressing Alt + F11 (Alt plus F11).

This will open VBA IDE as bellow.

VBA Editor
  1. In the VBA editor, from the menu click on Insert > then click on Module to create a new module.
Inserting New Module inside VBA Editor
  1. Paste or write the following code into the module. (This code resizes all images to 400×400 pixels, but you can adjust the dimensions in the code to whatever size you want, ).
Sub resizeImagesToSameSize()
Dim inlineGraphic As InlineShape
Dim drawingObject As Shape
  For Each inlineGraphic In ActiveDocument.InlineShapes
    inlineGraphic.Height = 400
    inlineGraphic.Width = 400
  Next inlineGraphic
  For Each drawingObject In ActiveDocument.Shapes
    drawingObject.Height = 400
    drawingObject.Width = 400
  Next drawingObject
End Sub

OR Past the following code if you would like to use InchesToPoints() function in place of pixel value (Click here to learn more about pixels, inches, points, and their conversions)

Sub resizeImagesToSameSize()
Dim inlineGraphic As InlineShape
Dim drawingObject As Shape
  For Each inlineGraphic In ActiveDocument.InlineShapes
    inlineGraphic.Height = InchesToPoints(3) 
    inlineGraphic.Width = InchesToPoints(3) 
  Next inlineGraphic
  For Each drawingObject In ActiveDocument.Shapes
    drawingObject.Height = InchesToPoints(3) 
    drawingObject.Width = InchesToPoints(3) 
  Next drawingObject
End Sub

and after pasting the code Click On Save icon or Click on Run Icon(if prompt message appear click on “Yes”) and Close the VBA editor as shown bellow.

resizing all images to the same size VBA Code

4. To test and Run your created VBA Coded Macros Press Alt+F8 from your keyboard this will display a list of VBA macros, select your created macro from the list of available options, and click on Run Button as shown bellow.

run VBA macro to resize all images to the same size

Finally your VBA macro will be executed and all images will be resized to the same size with a single Click. From now on, whenever you need to resize all images in your document to the same size, simply press ALT+F8 shortcut key, select your macro, and then click the Run button. You can also automate this process by assigning a keyboard shortcut to your macro. If want to learn how to assign a shortcut key to your VBA macros, click here.

I Hope this tutorial will help you to automate the process of resizing images to the same size in word document. if you have any question, suggestion or feedback contact feel free to contact us by using the detail given on our contact us page.

Thank You.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *