VBA & Macro Problems

How to Position Images in a Recorded Word Macro

Algirdas JasaitisAlgirdas Jasaitis Nov 3, 2026 870 views

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.

How to Position Images in a Recorded Word Macro
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the Visual Basic Editor

Press ALT + F11 to launch the Visual Basic Editor and locate your recorded macro within the Modules folder.

2
Read Selected Image Coordinates

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).

3
Create a Positioning Loop

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.

4
Save and Run

Save your modified macro and run it from the Developer tab to automatically apply the exact positioning to your target images.

Manually Write VBA Code for Floating Image Placement
Floating vs. Inline: Ensure your target images are formatted as floating shapes (e.g., Wrap Text set to Square, Tight, or In Front of Text) for the Top and Left VBA properties to function correctly.
Free Microsoft Office alternative

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. 1. Download and Install: Get the free WPS Office suite from the official website and easily install it on your PC or Mac.
  2. 2. Open Your Document: Launch WPS Writer and open your existing .doc or .docx documents with absolute layout fidelity.
  3. 3. Edit and Format Effortlessly: Utilize the intuitive Picture Tools in WPS Writer to effortlessly align images and manage visual layouts.
Free to use with a fast, lightweight installation processFully compatible with Microsoft Word (.docx), Excel, and PowerPoint formatsFamiliar user interface ensures seamless migration with zero learning curveRobust native tools for image layout, alignment, and text wrapping
microsoft office alternative - wps office

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.