Document Editing Problems

How to Automatically Add Page and Line Numbers to Word Comments

Bushra ParveenBushra Parveen Oct 26, 2026 868 views

Question details

The user wants to automatically insert the corresponding page and line numbers of selected text into a new comment when reviewing a document.

How to Automatically Add Page and Line Numbers to Word Comments
Product
Microsoft Word
Device & OS
not provided
Scenario
Reviewing or editing documents where precise location referencing within comments is required for collaboration.
Observed behavior
Microsoft Word lacks a built-in feature to automatically populate page and line numbers in new comments, requiring a manual workaround.
Before you start

Before running a VBA macro, ensure that you have enabled the Developer tab in your Word ribbon and have saved your document as a Macro-Enabled Document (.docm) to prevent losing your code.

Solution 1Recommended

Use a VBA Macro to Insert Page and Line Numbers

Create a custom VBA macro to fetch the page and line details of your selected text and automatically paste them into a newly created comment.

Since Word lacks a native feature for this, a macro (often named 'InsertAnnotation') can read the selected range's page and line information and insert it as text.

Please note that the inserted values are static text. If you edit the document, change the layout, or switch printer drivers, the pagination might shift, making the recorded line and page numbers in the comment inaccurate.

1
Open the VBA Editor

Press 'Alt + F11' on your keyboard to open the Visual Basic for Applications (VBA) editor.

2
Insert a New Module

Go to 'Insert' > 'Module' on the top menu to create a new blank module in your document project.

3
Add the Macro Code

Paste your customized VBA script designed to capture selection page and line properties into the module window.

4
Run the Macro

Select the text in your document, press 'Alt + F8', choose your new macro from the list, and click 'Run' to generate a comment with the location details.

Use a VBA Macro to Insert Page and Line Numbers
Static Values: The inserted text (e.g., 'Page 5, Lines 25–27') will not automatically update if subsequent document edits alter the page or line numbers.
Free Microsoft Office alternative

Try WPS Office for Seamless Document Reviewing and Editing

While Microsoft Word requires complex VBA macros for advanced comment formatting, WPS Office provides a lightweight, highly compatible, and user-friendly environment for all your document collaboration needs. It fully supports standard Microsoft Office formats and offers an intuitive interface for managing comments and revisions.

  1. 1. Download and Install: Get WPS Office from the official website and install it on your device.
  2. 2. Open Your Document: Launch WPS Writer and open your existing Word document without losing any formatting.
  3. 3. Use the Review Tools: Navigate to the 'Review' tab to easily add, reply to, and manage comments during collaboration.
Fully compatible with Microsoft Word documents (.doc and .docx)Intuitive comment, markup, and revision tracking tools built right inLightweight application that runs smoothly on Windows, Mac, and LinuxFree to download with a highly familiar user interface
microsoft office alternative - wps office

Frequently Asked Questions

Why do the page and line numbers in my comments become inaccurate over time?

The numbers added via a macro are inserted as static text. If you add or delete content, or change page margins, the document repaginates. However, the static text inside the comment remains unchanged, leading to inaccuracies.

Can printer drivers affect the page and line numbers in my document?

Yes, word processing software often relies on your default printer driver to calculate page layout and margins. Changing the default printer can slightly alter text wrapping, which in turn changes line and page numbers.

Is there a built-in feature in Word to automatically add line numbers to comments?

No, Microsoft Word currently does not provide a native, built-in feature to automatically include page and line numbers inside newly created comments. A custom VBA macro is the standard automated workaround.