How do I create a macro that uses the Replace command?

G

Guest

I am trying to create a macro that will delete all bold text using Edit and
Replace. I create the Macro, but it does not work. I think it may have
something to do with the dialog boxes that pop up after the replacements.
Any advice?
 
G

Graham Mayor

It has more to do with the inability of the macro recorder to record all the
replace functions. You will have to add the extra lines:

eg to remove all emboldened text (as opposed to removing the bold attribute)

Sub ReplaceExample()
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
'**********************
.Text = ""
.Font.Bold = True
.Replacement.Text = ""
'**********************
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
End With
Selection.Find.Execute replace:=wdReplaceAll
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top