How to Position Images in a Recorded Word Macro
Question details
The user wants to automate image positioning using a macro but found that the macro recorder does not capture actions related to image placement.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- Recording a macro to automate document formatting, specifically moving, resizing, and aligning graphics.
- Observed behavior
- The macro recorder ignores all operations involving graphics and image positioning, leaving the recorded script without any image alignment steps.
Ensure you have the Developer tab enabled in your word processor so you can access the Visual Basic Editor (VBE) to manually edit your macro code.
Manually Write VBA Code for Floating Image Placement
Since the recorder ignores graphics, you must write a VBA loop to manually set the Top and Left properties of floating images.
The built-in macro recorder does not support graphic operations. To automate image placement, you must manually write or modify the recorded macro using Visual Basic for Applications (VBA). The required code depends on the specific properties you want to change, such as position, size, and text wrapping.
Press ALT + F11 to launch the Visual Basic Editor and locate your recorded macro within the Modules folder.
Write VBA code to read the Top and Left properties of a selected floating image that is already positioned correctly (e.g., using Selection.ShapeRange.Top).
Write a loop in your VBA script (such as a For Each loop targeting the Shapes collection) to apply these Top and Left coordinates to other floating images in the document.
Save your modified macro and run it from the Developer tab to automatically apply the exact positioning to your target images.

Use a Table-Based Layout for Inline Images
Bypass complex VBA positioning code by using a table layout with fixed cell widths to automatically constrain and position inline images.
Looking for a Better Document Editing Experience?
Struggling with advanced formatting limitations in traditional word processors? Try WPS Office, a free, lightweight, and highly compatible alternative. It offers full compatibility with Microsoft Office formats, allowing you to edit documents, run standard macros, and format graphics flawlessly within a familiar interface.
- 1. Download and Install: Get the free WPS Office suite from the official website and easily install it on your PC or Mac.
- 2. Open Your Document: Launch WPS Writer and open your existing .doc or .docx documents with absolute layout fidelity.
- 3. Edit and Format Effortlessly: Utilize the intuitive Picture Tools in WPS Writer to effortlessly align images and manage visual layouts.

Frequently Asked Questions
Why didn't the macro recorder capture my image alignment steps?
The macro recorder in Word is primarily designed to capture text entry, deletions, and basic text formatting. It inherently ignores mouse clicks on graphical objects, shape movements, and advanced image property changes, requiring you to manually write VBA code for these tasks.
How do I find the positioning properties of an image in VBA?
You can access an image's layout coordinates by referencing it as a Shape object in VBA. Use 'Selection.ShapeRange.Top' and 'Selection.ShapeRange.Left' to get the exact positioning properties of a currently selected floating image.
Can I automate the sizing of inline images without using VBA code?
Yes. If you place your inline images into a table, you can right-click the table, select Table Properties, and disable 'Automatically resize to fit contents'. Once the cell widths are fixed, any inline image pasted into them will automatically be constrained to the cell dimensions without requiring macro automation.




