VBA & Macro Problems

Fix Empty Comments Created by a Word VBA Macro

Tauseeq MagsiTauseeq Magsi Nov 22, 2026 868 views

Question details

Prevent a Word VBA macro from creating an empty comment or placing comment text in the wrong comment.

Fix Empty Comments Created by a Word VBA Macro
Product
Microsoft Word
Device & OS
not provided
Scenario
A VBA macro adds comments to selected text, including after the user has worked with long comments.
Observed behavior
The macro occasionally creates an empty comment and places the intended text in the first comment.
Before you start

Open the document in Word and make sure the macro comes from a trusted source. Select the text you want to comment on before running the macro.

Solution 1Recommended

Add the comment through the active document's Comments collection

Use the selected range as the comment anchor and supply the comment text directly when creating it.

1
Open the macro editor

In Word, open the Developer tab and select Visual Basic, then find the macro that creates the comment.

2
Replace the comment-creation statement

Replace the existing comment-creation statement with: ActiveDocument.Comments.Add Range:=Selection.Range, Text:="My automatically inserted test comment." Replace the sample text with your intended comment text.

3
Run the macro on selected text

Return to the document, select the text to annotate, and run the macro from Developer > Macros.

4
Check the new comment

Open Review > Show Comments and verify that the new comment contains the intended text and is attached to the selected passage. Test again after working with a long comment.

Add the comment through the active document's Comments collection
Check the selection if the issue continues: This change can avoid selection-related errors, but it does not remove existing empty comments or guarantee a fix. Check that the intended document is active and that the selection has not changed before the statement runs.
Free Microsoft Office alternative

Review Word Documents with WPS Writer

WPS Office is a free, lightweight Office alternative with a familiar interface and Microsoft Word format compatibility. Open existing documents in WPS Writer for a smoother move between office suites; it does not repair Word's VBA behavior.

Review and comment on document content in WPS WriterOpen and edit Microsoft Word DOC and DOCX filesUse a familiar interface for everyday document workMove existing Word documents to a free, lightweight office suite
QA img-9

Frequently Asked Questions

Why use ActiveDocument.Comments.Add instead of relying on the Selection object?

ActiveDocument.Comments.Add creates the comment through the active document's Comments collection while using Selection.Range only as the anchor. Supplying Text in the same call can avoid some selection-related errors.

What should I check if the comment is attached to the wrong text?

Select the intended passage before running the macro from Developer > Macros. Also check whether another part of the macro changes the active document or selection before Comments.Add runs.

Will this change remove comments that are already empty?

No. The statement creates a new comment; it does not modify or delete existing comments. Use Review > Show Comments to find and remove unwanted comments.

How do I keep the macro in the Word document?

Use File > Save As and choose Word Macro-Enabled Document (.docm) if the macro is stored in the document.