Italicizing text WITHIN a mail merge field

B

Brent

I am importing records from an Access database into Word. I have another program feeding the data into Access. My problem is that one of the fields in Access is a memo field where users enter bibliographic information and have to italicize certain words. If they use <i></i> around what needs to be italicized, it looks good on the web but the <i></i> shows up in Word when the records are merged.

All I want to do is use something that tells word to take anything inside the <i></i> tags and italicize it and then delete the tags. Any suggestions?
 
G

Graham Mayor

Merge to a new document and use the replace function to remove the tags and
italicise the text - the following macro will do the job:

Sub ReplaceItalicTags()
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "\<i\>(*)\</i\>"
.Replacement.Text = "\1"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute replace:=wdReplaceAll
End Sub


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


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

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