VBA & Macro Problems

Fix a Word Comment Extract Macro to Export Full Paragraph Text

Huda QurayshiHuda Qurayshi Nov 22, 2026 868 views

Question details

The user needs a Word VBA macro to export the complete text surrounding each comment to Excel.

Fix a Word Comment Extract Macro to Export Full Paragraph Text
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the macro

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.

2
Replace the range extraction

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

3
Keep the Excel output

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.

4
Run and check the export

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.

Expand each comment range to its full paragraphs
Paragraph boundaries add text: The expanded range can include text outside the exact comment anchor and paragraph marks. If you need only the anchored text, use ActiveDocument.Comments(i).Scope.Text without expanding the range.
Free Microsoft Office alternative

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.

Review documents and comment-related text alongside spreadsheet exportsOpen and edit compatible Microsoft Word DOCX and Excel XLSX filesUse a familiar interface for everyday document and spreadsheet workMove between Office-compatible files with a lightweight suite
microsoft office alternative - wps office

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.