M
MarS
I am new to writing macros. In Word 2003 I have recorded a macro that Finds
& Replaces the font formatting and size when using wildcards (so that any
string of text between ;;*;; is formatted to Tahoma Bold 12 pt; or any text
between @*@ is formatted to Tahoma Regular 11pt, etc.). As I am recording
the macro, the font style and size is replaced correctly, but when I try to
run the macro in other documents (merged from a database) it just deletes the
text.
What am I doing wrong?
Example:
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "\;;*\;;"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.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
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
& Replaces the font formatting and size when using wildcards (so that any
string of text between ;;*;; is formatted to Tahoma Bold 12 pt; or any text
between @*@ is formatted to Tahoma Regular 11pt, etc.). As I am recording
the macro, the font style and size is replaced correctly, but when I try to
run the macro in other documents (merged from a database) it just deletes the
text.
What am I doing wrong?
Example:
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "\;;*\;;"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.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
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True