What can I say?
EXCELLENT!
Here is what I did with it, for the three options.
1) /* */ Green comment
2) -- Green comment
3) 'aaa' Red for literal's
Any ideas to make it better / faster / easier = or something I missed?
Love to learn and maybe someone else can use as well . . . .
Sub SQLComment()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
' Selection.Find.Replacement.Font.Color = wdColorGreen
With Selection.Find
.Text = "/*[!\/]*/"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Replacement.Font.Color = wdColorGreen
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "'[!\/]'"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Replacement.Font.Color = wdColorRed
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "--**^13"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Replacement.Font.Color = wdColorBlue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
m rafala - 13 Sep 2007 16:59 GMT
Hmmm...
What I typed is not quite what I intended.
Looks like I typed this: .Text = "/*[!\/]/"
It's better off like this: .Text = "/\*[!\/]@\*/"
which means essentially, find a slash, asterisk, a string of non-slashes,
asterisk, followed by a slash. The former works, but its not as precise (and
kind of pointless).
> What can I say?
>
[quoted text clipped - 68 lines]
> Selection.Find.Execute Replace:=wdReplaceAll
> End Sub