How to Fix Word Margins and Image Positioning After Running a Macro
Question details
The user needs to fix paragraph indents, page margins, and incorrect image positioning after executing a Word macro.

- Product
- Word
- Device & OS
- not provided
- Scenario
- Running a macro affects text fitting within margins and causes floating images to position incorrectly.
- Observed behavior
- Text exceeds page margins, and images move in the opposite direction of the selected alignment command (e.g., choosing 'Position Up' aligns the image to the bottom).
Before troubleshooting formatting issues, create a duplicate copy of your document to preserve your original layout and macro settings while testing solutions.
Remove Incorrect Paragraph Indents
Clear unwanted paragraph indents that push inline images and text outside the standard page margins.
Macros often apply hard-coded indent values to text blocks. Removing these manual indents allows the text and inline images to naturally wrap within the document's established margins.
Highlight the affected text and inline images in your document, or press 'Ctrl + A' to select the entire document.
Navigate to the 'Home' tab and click the small dialog box launcher arrow in the bottom-right corner of the 'Paragraph' group.
Under the 'Indents and Spacing' tab, set both the 'Left' and 'Right' indentation values to 0.
Click 'OK' to enforce the changes and verify that the text now fits properly inside the page margins.

Correct Image Wrapping and Anchor Settings
Fix floating images that move in the opposite direction of alignment commands by adjusting their text wrapping and object anchors.
Review Macro Code for Section Modifications
Check if the VBA macro inadvertently modifies section properties instead of standard page properties.
Easily Manage Margins and Macros in WPS Writer
WPS Writer provides intuitive page layout tools and robust macro support, allowing you to control margins, adjust image wrapping, and run VBA scripts safely without unintended formatting errors.
- 1. Open your document: Launch WPS Writer and open the document experiencing formatting issues.
- 2. Set page margins: Navigate to the 'Page Layout' tab to easily adjust margins and manage section breaks.
- 3. Adjust image wrapping: Select any image and use the quick-access Layout Options button that appears next to it to define wrapping and anchor behavior.
- 4. Manage macros securely: Access the 'Developer' tab to safely review, edit, and run your VBA macro scripts with full compatibility.

Frequently Asked Questions
Why do my images align to the bottom when I select 'Position Up'?
This reversed behavior often occurs when an image's vertical position is anchored relative to an inverted or negatively offset paragraph, or if a macro has corrupted the relative position settings. Resetting the image vertical position relative to the 'Page' or 'Margin' instead of the 'Paragraph' resolves this.
Do margins apply to the whole page or just a section?
In document formatting, margins are strictly section properties rather than document-wide properties. If your document contains multiple sections, changing the margins in one specific section will not affect the layout of the others unless you specifically apply the changes to the 'Whole document'.
Can a macro permanently prevent manual position changes to images?
A macro itself doesn't actively block manual changes after it has finished executing. However, if the macro locked the image anchor or changed the image to an 'Inline with text' wrapping style, it restricts manual dragging until you change the wrapping style to floating and unlock the anchor.




