Macro for several replacements in Word 2003

A

Arnica

I'm trying to set up a macro (Word 2003) to do several replacements in
selection of my text with italics in the replacement field.

I.e. I have a certain number of words (non italic) that need to b
replaced with another word in italic.

I recorded the sequence for one of the words (actually, these are name
of notes that need to be translated and italicized, A>LA, B>SI, etc.)
and then copied it for each word.

My problem is that the italics don't get inserted with the macro, thoug
they appeared when I recorded it.

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "A"
.Replacement.Text = "LA"
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = True
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll

What do I need to add to get the italics?

Many thanks
 
J

JWeissmn

Try removing this line:

Selection.Find.Replacement.ClearFormatting

which removes the italic formatting from your replacement text
 
A

Arnica

JWeissmn;492137 said:
Try removing this line:

Selection.Find.Replacement.ClearFormatting

which removes the italic formatting from your replacement text.

Thank you. Indeed, that's what I was suspecting. But I nevertheless nee
to add the italics, since they aren't there to begin with:

Selection.Find.Replacement.Font.Italic = True

I got this line by recording the same macro in Word 2000. The mystery i
why it doesn't appear when I record exactly the same thing in Word 2003
where I get this line instead:

Selection.Find.Replacement.ClearFormatting

Any explanation for this behavior?

Thanks
 

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