How to Resize Multiple Images in Word Using VBA
Question details
The user wants to resize all inline images in a Word document simultaneously using a VBA macro to avoid manually cropping or adjusting each picture individually.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- Editing a document containing numerous inline images that require uniform height and width dimensions for consistent formatting.
- Observed behavior
- Currently, images have varying sizes and must be manually adjusted one by one. The goal is to apply a VBA script that automatically sets a specific width and height to all inline shapes.
Ensure your document is saved as a backup before executing the script, and verify that your images are formatted as 'In Line with Text' so the macro can detect them.
Create and Run a VBA Macro to Batch Resize Images
Use Word's built-in Visual Basic for Applications (VBA) editor to run a simple script that iterates through all inline images and applies your preferred height and width measurements.
This solution utilizes a VBA macro to target the 'InlineShapes' collection within your active document. You can customize the height and width values directly within the code to match your document's layout needs.
Press the 'Alt + F11' shortcut on your keyboard to launch the Microsoft Visual Basic for Applications window.
In the top menu bar of the VBA editor, click 'Insert' and select 'Module' to create a new blank coding environment.
Copy and paste the following code into the module window: Sub SetPictureSize() Dim n As Long On Error Resume Next For n = 1 To ActiveDocument.InlineShapes.Count ActiveDocument.InlineShapes(n).Height = 198.45 ActiveDocument.InlineShapes(n).Width = 283.5 Next n End Sub
Close the VBA editor to return to your document. Press 'Alt + F8' to open the Macros dialog box, select 'SetPictureSize' from the list, and click 'Run'. All inline images will automatically update to the specified dimensions.

Experience Seamless Document Editing with WPS Office
If you find complex Word macros overwhelming or want a lighter suite for document editing, WPS Office offers a free, highly compatible, and user-friendly alternative. It handles heavy image formatting and layout adjustments effortlessly, ensuring peak productivity without the steep learning curve.
- 1. Download WPS Office: Visit the official WPS website and download the free software installer.
- 2. Install the Software: Run the setup file and follow the on-screen prompts to easily install WPS Office on your system.
- 3. Open Your Document: Launch WPS Writer and open your existing Word document to experience intuitive document formatting and image management.

Frequently Asked Questions
Why did the VBA macro not resize all the pictures in my document?
The provided macro specifically targets 'InlineShapes'—images formatted as 'In Line with Text'. If some images are formatted with text wrapping (such as 'Square', 'Tight', or 'Behind Text'), Word classifies them as 'Shapes', which requires a different VBA loop to modify.
How do I calculate measurements in inches or centimeters for the VBA code?
Word VBA calculates height and width values in points (1 inch equals 72 points). Instead of doing the math manually, you can use Word's built-in conversion functions directly in your macro. For example, use `CentimetersToPoints(5)` or `InchesToPoints(2)` instead of fixed numerical values.
How can I easily unlock the aspect ratio before running the macro?
Select an image, navigate to the 'Picture Format' tab, and click the small dialog launcher arrow in the bottom right of the 'Size' group. In the Layout window, uncheck the 'Lock aspect ratio' box. You may need to do this manually for images you plan to distort independently.
Is there a way to undo a macro after it finishes running?
Standard VBA macros typically clear the 'Undo' history in Microsoft Word, meaning you cannot simply press Ctrl+Z to revert the batch adjustments. It is highly recommended to always save a duplicate or backup copy of your document before executing any batch-processing scripts.




