M
Mark F.
I have the following macro that is supposed to change all the keywords
in a Word document to blue. This macro however does not work. Any help
would be appreciated.
Thanks!
'
========================================================================
==
Sub Colorize()
'
' Colorize Macro
'
========================================================================
==
Dim sKeywords, i As Integer
sKeywords = Array( _
"Alias", "As", "ByRef", "ByVal", "Const", "Declare", "Dim", _
"Do", "Double", "Each", "Else", "End", "For", "Function", _
"If", "Integer", "Lib", "Long", "Loop", "New", "Next", _
"Private", "Public", "Short", "Sub", "Then", "Until", _
"Wend", "While")
For i = LBound(sKeywords) To UBound(sKeywords)
Selection.Find.ClearFormatting
With Selection.Find
.Text = sKeywords(i)
.Replacement.Text = sKeywords(i)
.Forward = True
.Font.Color = wdColorBlue
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Next i
End Sub
' ====== end =========================================================
in a Word document to blue. This macro however does not work. Any help
would be appreciated.
Thanks!
'
========================================================================
==
Sub Colorize()
'
' Colorize Macro
'
========================================================================
==
Dim sKeywords, i As Integer
sKeywords = Array( _
"Alias", "As", "ByRef", "ByVal", "Const", "Declare", "Dim", _
"Do", "Double", "Each", "Else", "End", "For", "Function", _
"If", "Integer", "Lib", "Long", "Loop", "New", "Next", _
"Private", "Public", "Short", "Sub", "Then", "Until", _
"Wend", "While")
For i = LBound(sKeywords) To UBound(sKeywords)
Selection.Find.ClearFormatting
With Selection.Find
.Text = sKeywords(i)
.Replacement.Text = sKeywords(i)
.Forward = True
.Font.Color = wdColorBlue
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Next i
End Sub
' ====== end =========================================================