logo
search
Document Editing Problems

How to Create a Word VBA Macro for Continued Headings Across Pages

Camila MilosovichCamila Milosovich Oct 22, 2026 868 views

Question details

The user needs to automate the process of formatting a heading (such as Heading 4) that continues across multiple pages by using a VBA macro to insert page breaks and continuation notices.

How to Create a Word VBA Macro for Continued Headings Across Pages
Product
Microsoft Word
Device & OS
not provided
Scenario
Editing long or complex documents where specific heading sections span across multiple pages and require explicit "Continued on next page" notices for better readability.
Observed behavior
By default, Word automatically flows text to the next page without adding continuation notices. A custom VBA macro is required to detect the cross-page flow, insert right-aligned italic notices, add a page break, and format the continuation text.
Before you start

Before running custom VBA scripts, ensure that you have enabled the Developer tab in your ribbon and always test the macro on a backup copy of your document to prevent irreversible formatting changes.

Solution 1Recommended

Implement a Custom VBA Macro for Continued Headings

Use a specialized VBA macro to automate the detection of page breaks within heading sections and dynamically insert "Continued on next page" notices.

Because Word does not natively support automated "Continued" notices for headings spanning multiple pages, a custom VBA script is the most effective solution. The script evaluates text flow, identifies the boundaries of the specified heading (e.g., Heading 4), and injects the necessary text and breaks.

1
Open the VBA Editor

In Microsoft Word, press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) Editor. If you prefer using the ribbon, navigate to the Developer tab and click on 'Visual Basic'.

2
Insert a New Module

In the VBA Editor, right-click on your document project in the Project Explorer pane on the left. Select 'Insert' > 'Module' to create a blank workspace for your custom code.

3
Paste the Continuation Macro Code

Paste your custom VBA macro code designed to detect cross-page headings. Ensure the script includes instructions to insert a right-aligned, italicized "Continued on next page" notice and a manual page break before reapplying the Heading 4 style on the new page.

4
Run the Macro

Close the VBA Editor and return to your document. Go to the Developer tab, click 'Macros', select your newly created macro from the list, and click 'Run'. Review the document to ensure the notices were placed correctly.

Implement a Custom VBA Macro for Continued Headings
VBA Implementation Reference: Writing a macro that perfectly detects page boundaries can be highly complex depending on your document's layout. It is highly recommended to consult developer communities like Stack Overflow for tailored script examples specific to this "Heading 4 continued" requirement.
Free Microsoft Office alternative

Experience Seamless Document Editing with WPS Office

If you are struggling with complex formatting issues and intricate VBA macro setups in Microsoft Word, consider switching to WPS Office. It offers an intuitive interface and robust style management, making manual and automated document formatting a breeze without a steep learning curve.

  1. 1. Download and Install: Visit the official WPS website to download the free WPS Office suite and follow the simple installation instructions.
  2. 2. Open Your Document: Launch WPS Writer and seamlessly open your existing Word documents with full layout retention.
  3. 3. Manage Styles Easily: Use the highly accessible Home and Page Layout tabs to quickly adjust heading styles and manage page breaks without needing complex code.
Fully compatible with Microsoft Word formats (.docx, .doc, .docm)Intuitive and user-friendly interface for managing styles, headings, and page layoutsLightweight application that runs smoothly even on older devicesCompletely free to download for your everyday document creation and editing needs
microsoft office alternative - wps office

Frequently Asked Questions

Can I apply this macro to headings other than Heading 4?

Yes, you can modify the VBA code to target other heading levels. Simply locate the section of the script that references the style name (e.g., 'Heading 4') and change it to 'Heading 1', 'Heading 2', or the name of any custom style you are using.

Why doesn't the macro run on my Word document?

Your document might be saved in a standard, macro-disabled format (.docx). To execute macros, you must save the file as a Word Macro-Enabled Document (.docm). Additionally, check your Trust Center settings to ensure macro execution is permitted.

How do I manually add a page break and continuation notice without a macro?

Place your cursor at the end of the text on the current page, press Ctrl + Enter to insert a manual Page Break. Then, right-align your text cursor, manually type 'Continued on next page' in italics, and apply your desired heading style to the continuation text on the new page.