Solved: Word: Find and add Comment Macro
Greetings,
I have been working as an technical editor and spend a lot of time adding comments to documents I recieve. I'm a bit of a novice and would like to know if there is a way to improve the macro or vbscript (below) I found this on the web but it is very slow and I dont know enough to improve upon it. Can anyone help?
Public Sub addComments()
Dim intCount As Integer
Dim strSearch As String
Dim strComment As String
Dim intDiff As Integer
strSearch = InputBox("Please enter the word to search for:", "Search")
strComment = InputBox("Please enter the comment you wish to add to all instances of [" & strSearch & "].", "Search")
For intCount = 1 To ActiveDocument.Words.Count
With ActiveDocument
If (LCase(Trim(.Words(intCount).Text)) = strSearch) Then
intDiff = Len(.Words(intCount).Text) - Len(Trim(.Words(intCount).Text))
'.Words(intCount).Font.Italic = True
.Comments.Add .Range(.Words(intCount).Start, (.Words(intCount).End - intDiff)), strComment
'Uncomment the lines below to add event handling while process is running
'If (intCount Mod 2) = 1 Then
' DoEvents
'End If
End If
End With
Next
End Sub
Public Sub remComments()
Dim intCount As Integer
For intCount = 1 To ActiveDocument.Comments.Count
ActiveDocument.Comments(1).Delete
Next
End Sub