S
Sandi V
I recorded a macro in Word 2003 that searches for a word and then applies a
character style to that word and to the following word. Then I found the
answer on these boards how to loop through the rest of the document. But
when I run the macro I get the "expected Function or Variable" error. Could
somebody please assist? Thanks in advance.
--Sandi
Sub SectionStyle()
'
' SectionStyle Macro
' Searches for the word Section and applies the Section character Style to
that word and the following word
'
With Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "section"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdWord, Count:=2, Extend:=wdExtend
Selection.Style = ActiveDocument.Styles("section Char")
Loop
End With
End Sub
character style to that word and to the following word. Then I found the
answer on these boards how to loop through the rest of the document. But
when I run the macro I get the "expected Function or Variable" error. Could
somebody please assist? Thanks in advance.
--Sandi
Sub SectionStyle()
'
' SectionStyle Macro
' Searches for the word Section and applies the Section character Style to
that word and the following word
'
With Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "section"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdWord, Count:=2, Extend:=wdExtend
Selection.Style = ActiveDocument.Styles("section Char")
Loop
End With
End Sub