Double comments generated

C

Charlie Mac

I am using this code to detect specific grammar errors (e.g. starting
a sentence with 'However...') and all works well until it nears the
end of a document. Near the end of a document two identical comments
are generated for each error. The length of the document does not
seem to matter. If 30 errors are detected, about 4 or 5 of the last
ones will have duplicated comments. The loop is needed to scan the
entire document for multiple copies of the same error. Any ideas are
appreciated. Thanks.

Bray(eye,1) = "However"
Bray(eye,2) = "Avoid starting a sentence with 'However'"

Do While Selection.Find.Execute(FindText:=Bray(Eye, 1), Forward:=True,
Format:=True) = True
Selection.Comments.Add Range:=Selection.Range, Text:=Bray(Eye, 2)
Loop
 
D

Doug Robbins - Word MVP

Maybe you need to include the Wrap attribute

Wrap:=wdFindStop

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
C

Charlie Mac

Doug,

Thanks. I will try your suggestion. I did solve the problem by
inserting Selection.GoTo What:=wdGoToHeading, Which:=wdGoToFirst
immediately after the do while loop. I am new to this...so this was
probably a brute-force solution. Thanks again.

Mac
 

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