How to Automatically Add Page and Line Numbers to Word Comments
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.

- 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 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.
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.
Press 'Alt + F11' on your keyboard to open the Visual Basic for Applications (VBA) editor.
Go to 'Insert' > 'Module' on the top menu to create a new blank module in your document project.
Paste your customized VBA script designed to capture selection page and line properties into the module window.
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.

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. Download and Install: Get WPS Office from the official website and install it on your device.
- 2. Open Your Document: Launch WPS Writer and open your existing Word document without losing any formatting.
- 3. Use the Review Tools: Navigate to the 'Review' tab to easily add, reply to, and manage comments during collaboration.

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.




