VBA & Macro Problems

How to Add Page Labels After Manual Page Breaks in Word Using VBA

Chanuka GeekiyanageChanuka Geekiyanage Oct 29, 2026 870 views

Question details

The user needs to insert custom, accessible page labels (such as "[Page 1]") immediately after manual page breaks using a VBA macro, avoiding standard headers and footers.

How to Add Page Labels After Manual Page Breaks in Word
Product
Word
Device & OS
not provided
Scenario
Preparing a document with fixed page boundaries for accessibility purposes where standard page numbering controls aren't sufficient.
Observed behavior
The user attempted a VBA script, but the page labels appeared at the top of the document instead of directly after each manual page break.
Before you start

Before running any VBA macro, ensure your document's manual page breaks are finalized, as inserting text directly into the document body can alter pagination and shift your layout.

Solution 1Recommended

Use a VBA Macro to Insert Labels After Page Breaks

Execute a customized VBA script to search for manual page breaks and insert your specific page label format.

Since Word reflows text dynamically, hardcoding page numbers into the body can be tricky. A VBA macro can automate finding manual page breaks (^m) and appending custom text like '[Page X]' directly after them.

1
Open the VBA Editor

Press Alt + F11 to open the Visual Basic for Applications (VBA) Editor in Word.

2
Insert a New Module

Go to the 'Insert' menu at the top and select 'Module' to create a blank script window.

3
Paste the Macro Code

Write or paste a VBA script designed to loop through the document's Find object, searching for manual page breaks (^m) and inserting the label text with an incrementing counter variable.

4
Run the Macro

Press F5 or click the 'Run' button. Check the document to verify that the labels appear correctly after each break.

Use a VBA Macro to Insert Labels After Page Breaks
Pagination Warning: Text insertion takes up physical space on the page. Review your document format after running the macro to ensure content hasn't been pushed to unintended new pages.
Free Microsoft Office alternative

Automate Document Formatting with WPS Writer

WPS Office provides robust support for VBA macros and advanced document formatting. You can easily manage manual page breaks, insert custom fields, and ensure your documents are accessible without hassle.

  1. 1. Install WPS Office: Download and install WPS Office for free from the official website.
  2. 2. Open Your Document: Launch WPS Writer and open your existing document containing manual page breaks.
  3. 3. Access the Developer Tools: Go to the Developer tab to access the VBA Editor and write or paste your macro.
  4. 4. Execute or Insert Fields: Run the macro or use the 'Insert' tab to manually place field codes for your custom page labels.
Full compatibility with Microsoft Word documents (.docx).Built-in VBA macro support for advanced automation tasks.Insert inline fields and custom page numbers effortlessly.Easy PDF export with accessibility features built-in.Lightweight, fast, and completely free to use.
microsoft office alternative - wps office

Frequently Asked Questions

Why does inserting text after a page break change my document layout?

Word processors dynamically reflow text based on page size and margins. Adding fixed text like a page label directly into the body takes up space, which can push subsequent lines onto a new page if the current page is already full.

How can I start my page labels at a number other than 1?

In your VBA macro, you can initialize your counter variable to your desired starting number before starting the find-and-replace loop. If using inline Page fields, you can adjust the starting page number in the 'Page Number Format' dialog box.

Can I use page number fields outside of headers and footers?

Yes. You can insert a Page Number field anywhere in the document body by pressing Ctrl+F9, typing 'PAGE' inside the field brackets, and pressing F9 to update it.

Why is exporting to PDF recommended for screen readers?

PDFs lock the visual layout and pagination, preventing unwanted text reflow. They also support strict accessibility tags that screen readers can parse reliably, making document navigation easier for visually impaired users.