Document Editing Problems

How to Use VBA to Bold the Paragraph After a Specific Letter in Word

Anum MushtaqAnum Mushtaq Nov 3, 2026 870 views

Question details

The user wants to automate the process of finding a specific letter or character in a document and applying bold formatting to the paragraph immediately following it using VBA.

How to Use VBA to Bold a Paragraph After a Specific Letter
Product
Word
Device & OS
not provided
Scenario
Automating document formatting for structured text or right-to-left languages based on specific trigger characters.
Observed behavior
The user needs a working VBA macro script to achieve conditional bold formatting for paragraphs succeeding a specified target character.
Before you start

Ensure your document is saved as a Macro-Enabled Document (.docm) to preserve your VBA code. It is also highly recommended to create a backup copy of your document before running new macros to prevent accidental formatting loss.

Solution 1Recommended

Apply Bold to the Following Paragraph Using Standard VBA

Use a standard VBA macro loop to locate a specific character and bold the paragraph directly beneath it.

This solution utilizes the Find object in VBA to locate a target character, redefines the selection range, and shifts it to the next paragraph to apply the bold font property.

1
Open the VBA Editor

In your word processor, press ALT + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.

2
Insert a New Module

Click on 'Insert' in the top menu bar and select 'Module' to create a blank script window.

3
Draft the Macro Code

Write a script that uses Selection.Find to locate your character (e.g., '#'). Set a Range object (rng), use 'rng.MoveStart wdParagraph, 1' to move to the next paragraph, and apply 'rng.Paragraphs(1).Range.Font.Bold = True'.

4
Run the Macro

Press F5 or click the green 'Run' button in the toolbar to execute the macro. The script will loop through the document and bold every paragraph following your specified character.

Apply Bold to the Following Paragraph Using Standard VBA
Wildcards and Match Case: Ensure MatchWildcards is set to False and MatchCase is set to True in your Find operation to avoid accidentally targeting the wrong characters.
Advanced Document Formatting

Use Macros to Automate Formatting in WPS Writer

WPS Office supports VBA macros, allowing you to automate repetitive formatting tasks like conditional bolding seamlessly. With high compatibility with Microsoft Word documents, you can run your existing VBA scripts directly in WPS Writer.

  1. 1. Open WPS Writer: Launch WPS Office and open the document where you want to apply the conditional formatting.
  2. 2. Enable Developer Tools: Navigate to the 'Developer' tab on the top ribbon. If it is hidden, enable it in the settings.
  3. 3. Open VBA Editor: Click on 'Macros' or 'Visual Basic', or simply press ALT + F11 to access the built-in macro editor.
  4. 4. Insert and Run Code: Insert a new module, paste your bolding macro script, and click Run to format your document automatically.
Fully compatible with Microsoft Word .docm and .doc macro filesSupports standard VBA syntax and formatting objectsLightweight, fast, and completely free for basic editing needs
microsoft office alternative - wps office

Frequently Asked Questions

Why is my VBA macro not bolding the correct paragraph?

This usually happens if the target character is not unique or if the document structure uses line breaks (Shift+Enter) instead of standard paragraph breaks (Enter). Ensure your document uses true paragraph markers.

What is the difference between Font.Bold and Font.BoldBi in VBA?

Font.Bold is used for standard left-to-right languages like English. Font.BoldBi is a bidirectional property specifically required to apply bold formatting to right-to-left (RTL) languages such as Hebrew or Arabic.

Can I reverse the bold formatting if the macro makes a mistake?

Running a macro often clears the standard undo history, meaning you cannot simply press Ctrl+Z. It is highly recommended to save a backup of your document before running the macro, or you can write a separate macro to select all text and set Font.Bold = False.