Fix a Word Comment Extract Macro to Export Full Paragraph Text
Question details
The user needs a Word VBA macro to export the complete text surrounding each comment to Excel.

- Product
- Microsoft Word and Microsoft Excel
- Device & OS
- not provided
- Scenario
- A Word macro extracts the text associated with comments and writes it to an Excel worksheet.
- Observed behavior
- The macro may export only part of the associated paragraph when it relies on paragraph breaks.
Open the document containing the comments and locate the macro that exports them to Excel. Identify the loop that processes each comment and the variable used to store its associated text.
Expand each comment range to its full paragraphs
Use this change when the Excel export should include every complete paragraph touched by a comment.
A comment's Scope represents its anchored text. Expanding that range to paragraph boundaries includes the full first and last paragraphs, even if the comment covers only part of them.
In Word, open Developer > Visual Basic and find the macro that loops through ActiveDocument.Comments. If the Developer tab is hidden, enable it in Word's ribbon settings.
Inside the existing comment loop, replace the paragraph-break extraction with the following code, using the loop's comment index in place of i if it has a different name: Set myRange = ActiveDocument.Comments(i).Scope myRange.Start = myRange.Paragraphs(1).Range.Start myRange.End = myRange.Paragraphs(myRange.Paragraphs.Count).Range.End strSection = myRange.Text
In the same loop, retain the existing statement that writes strSection to the appropriate Excel cell. Make sure myRange is declared as a Word Range and strSection as a String if they are not already declared.
Run the macro from Word's Developer > Macros menu, then open the resulting Excel worksheet and compare the exported text with comments that cover part of a paragraph and comments that span multiple paragraphs.

Review Word documents and Excel exports with WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with documents and spreadsheets. Open compatible Office files to make migration easier; repairing or running this Microsoft Word VBA macro still requires checking its compatibility separately.

Frequently Asked Questions
How do I export only the text directly anchored to a comment?
In the comment loop, assign ActiveDocument.Comments(i).Scope.Text to strSection without changing the range's Start or End.
Will the expanded range include multiple paragraphs?
Yes. Setting the start to the first paragraph's start and the end to the last paragraph's end captures the full paragraphs touched by the comment, including text outside its exact anchor.
Where do I edit the Word macro?
In Word, open Developer > Visual Basic and locate the macro in the document or template project. Find the loop that processes ActiveDocument.Comments before changing the extraction code.
Why are paragraph marks included in the exported text?
Word paragraph ranges normally include their paragraph marks. The macro assigns myRange.Text to strSection, so those marks can appear in the Excel cell along with the paragraph text.




