W
wleonard47
Good day,
I am trying to change the font color for any line in a document that begins
with an apostrophe. I do this to highlight the comment lines when I have
pasted VBA code into a Word doc after copying it from the VB editor. I have
succeded in being able to do this when the first character of a line is A or
B or C, etc., but cannot get the macro to detect the apostrophe symbol. I
tried " ' " and Chr(39), but to no avail. Is there some magic regarding the
apostrophe? Code follows:
Sub wflFindandReplaceTest1()
Dim X As Integer
Dim rngParagraph As Range
Dim intParaCount As Integer
intParaCount = ActiveDocument.Paragraphs.Count
For X = 1 To intParaCount
Set rngParagraph = ActiveDocument.Paragraphs(X).Range
If rngParagraph.Characters.First = Chr(84) Then
rngParagraph.Font.Color = wdColorGreen
End If
Next X
End Sub
Thank you
Bill Leonard
Hingham, MA
I am trying to change the font color for any line in a document that begins
with an apostrophe. I do this to highlight the comment lines when I have
pasted VBA code into a Word doc after copying it from the VB editor. I have
succeded in being able to do this when the first character of a line is A or
B or C, etc., but cannot get the macro to detect the apostrophe symbol. I
tried " ' " and Chr(39), but to no avail. Is there some magic regarding the
apostrophe? Code follows:
Sub wflFindandReplaceTest1()
Dim X As Integer
Dim rngParagraph As Range
Dim intParaCount As Integer
intParaCount = ActiveDocument.Paragraphs.Count
For X = 1 To intParaCount
Set rngParagraph = ActiveDocument.Paragraphs(X).Range
If rngParagraph.Characters.First = Chr(84) Then
rngParagraph.Font.Color = wdColorGreen
End If
Next X
End Sub
Thank you
Bill Leonard
Hingham, MA