logo
search
VBA & Macro Problems

How to Fix Word Macro Formatting Only the First Paragraph

Kushani NimanthikaKushani Nimanthika Oct 10, 2026 869 views

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.

How to Fix a Word Macro Formatting Only the First Paragraph
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 you start

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.

Solution 1Recommended

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.

1
Open the VBA Editor

Press Alt + F11 to open the Visual Basic for Applications editor and locate the module containing your formatting macro.

2
Introduce a Loop

Delete the line 'Set oPar = Selection.Paragraphs(1)' and replace it with a loop initialization: 'For Each oPar In Selection.Paragraphs'.

3
Wrap the Formatting Code

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.

4
Save and Test

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.

Macro Updated Successfully: Your macro will now seamlessly format every paragraph included in your text selection without missing the subsequent ones.

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. 1. Open Your Document: Launch WPS Writer and open the document containing the paragraphs you wish to format.
  2. 2. Select the Text: Highlight all the paragraphs that require reduced font size or modified indentation.
  3. 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. 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.
Fully compatible with Microsoft Word document formats (.docx).Advanced Styles panel for quick, consistent multi-paragraph formatting.Built-in support for VBA macros in professional editions.Lightweight, fast, and features a familiar, easy-to-use interface.
QA img-9

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.