Add comments into document

  • Thread starter brendon shaw via OfficeKB.com
  • Start date
B

brendon shaw via OfficeKB.com

I am trying to write a VB6 application which will open a text file, pull out text strings and search of them in a Word document. If the text string is found, it adds a comment with some appropriate text.

I am having major problems trying to get a comment added into the Word document. I seam to every thing set-up, but when I come to run the line I get an error regarding the comment can only be added to the main story.

Any help would be appreciated.
 
D

Doug Robbins

From the VBA Help File:

This example adds a comment at the insertion point.

Sub AddComment()
Selection.Collapse Direction:=wdCollapseEnd
ActiveDocument.Comments.Add _
Range:=Selection.Range, Text:="review this"
End SubThis example adds a comment to the third paragraph in the active
document.

Sub Comment3rd()
Dim myRange As Range

Set myRange = ActiveDocument.Paragraphs(3).Range
ActiveDocument.Comments.Add Range:=myRange, _
Text:="original third paragraph"
End Sub
--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top