How to Fix Word Macro Formatting Only the First Paragraph
Question details
The user needs to modify a Word macro so it reduces font size, paragraph indentation, and line spacing for all paragraphs in a selection, rather than just the first one.

- Product
- Word
- Device & OS
- not provided
- Scenario
- Applying repetitive formatting changes to multiple highlighted paragraphs simultaneously using a VBA macro.
- Observed behavior
- The macro currently uses Selection.Paragraphs(1), which restricts the execution to only the first paragraph of the selected text, ignoring the rest of the multi-paragraph selection.
Before modifying your macro, turn on nonprinting characters (Show/Hide ¶) in your document to ensure your text is separated by true paragraph marks and not just manual line breaks.
Loop Through All Paragraphs in the Selection via VBA
Modify your VBA code to iterate through every paragraph within the user's selection instead of hardcoding it to the first paragraph.
The reason the macro only formats a single paragraph is the explicit use of 'Selection.Paragraphs(1)'. By replacing this with a 'For Each' loop, the macro will process all highlighted paragraphs dynamically.
Press Alt + F11 to open the Visual Basic for Applications editor and locate the module containing your formatting macro.
Delete the line 'Set oPar = Selection.Paragraphs(1)' and replace it with a loop initialization: 'For Each oPar In Selection.Paragraphs'.
Ensure all your formatting adjustments (like .Range.Font.Size and .LineSpacing) remain inside the 'With oPar' block, and close the loop by typing 'Next oPar' at the end of the script.
Save your macro, return to your document, select multiple paragraphs, and run the macro to verify the font size and indentation reduce for the entire selection.
Use Paragraph Styles for Consistent Formatting
Instead of relying on VBA macros for direct formatting, create and apply custom paragraph styles to quickly change font size and indentation across multiple paragraphs.
Manage Formatting and Macros Seamlessly in WPS Writer
WPS Writer offers powerful Paragraph Style management and full compatibility with Microsoft Word formatting. You can easily adjust indentation, line spacing, and font sizes across multiple paragraphs instantly, or utilize advanced VBA macro support.
- 1. Open Your Document: Launch WPS Writer and open the document containing the paragraphs you wish to format.
- 2. Select the Text: Highlight all the paragraphs that require reduced font size or modified indentation.
- 3. Apply Paragraph Styles: Navigate to the 'Home' tab and expand the 'Styles' panel to apply a unified paragraph style instantly to the entire selection.
- 4. Adjust Formatting Directly: Alternatively, click the 'Settings' icon in the Paragraph group to manually define precise line spacing and indentation rules for all selected text at once.

Frequently Asked Questions
Why does my macro only affect the first line of my selection?
If your VBA code uses 'Selection.Paragraphs(1)', it explicitly targets only the first paragraph. Also, check if your text uses manual line breaks (inserted with Shift+Enter) instead of true paragraph marks (Enter). Line breaks make the software treat multiple lines as a single paragraph.
How do I view paragraph marks in my document?
Go to the 'Home' tab and click the 'Show/Hide ¶' button. This reveals hidden formatting symbols, helping you distinguish between actual paragraph marks (¶) and manual line breaks (↵).
Can I automatically update a style to match my current selection?
Yes. Right-click the style in the Styles gallery and select 'Update [Style Name] to Match Selection'. This immediately applies the new font size and indentation to all other paragraphs in the document that use that specific style.
Is it better to use VBA macros or Styles for basic document formatting?
Paragraph styles are generally recommended for standard formatting because they are built into the word processor, update automatically, and avoid VBA security blocks. Macros are better reserved for complex logic or repetitive conditional tasks.




