OK, I got it all to work. I was able to remove a lot of stuff (commented out here):
Code:
Sub TextToComments()
Dim oDoc As Document
Dim oRng As Range
Dim MyString As String
'Dim myUsername As String
'Dim myUserinitials As String
Dim oComment As Comment
'myUsername = Application.UserName
'myUserinitials = Application.UserInitials
'Application.UserName = "JSmith"
'Application.UserInitials = "JS"
Application.ScreenUpdating = False
Set oDoc = ActiveDocument
oDoc.TrackRevisions = False
Set oRng = oDoc.Range
oRng.Paragraphs.LineSpacingRule = wdLineSpaceSingle
With oRng.ParagraphFormat
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 6
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
End With
With oRng.Find
With .Font
.Bold = True
End With
Do While .Execute(FindText:="(\[*\])", MatchWildcards:=True, _
Format:=True)
MyString = oRng.Text
MyString = Mid(MyString, 2, Len(MyString) - 2)
If Not Left(MyString, 3) = "TS:" Then
'MyString = Mid(MyString, InStr(1, MyString, ":") + 2)
oRng.Text = MyString
oRng.Delete
Set oComment = oDoc.Comments.Add(oRng, MyString)
oComment.Author = "MNathan"
'If Val(Application.Version) > 14 Then
' oComment.Author = Application.UserName
'End If
oRng.Font.Bold = False
End If
oRng.Collapse 0
Loop
End With
oRng.Collapse 1
oRng.Select
Application.ScreenUpdating = True
'Application.UserName = myUsername
'Application.UserInitials = myUserinitials
lbl_Exit:
Set oDoc = Nothing
Set oRng = Nothing
Set oComment = Nothing
Exit Sub
End Sub
Just one final question: do I even need "Application.ScreenUpdating = False" since I'm no longer using the Selection object?
Thanks for all your help. My next project is creating a macro to change a text highlighted in one color to another color, but I want the user to specify both of the colors. It will be my first crack at a userform, I think. Exciting!
Actually, that leads me to a Final final question re: userforms: Is Word's highlight color button (with the little squares of color) available to use in userforms? That would simplify things... maybe.
Thanks again.