Font problem in a Word 2003 merge

S

Sheahan

In my main document, the fonts of the merge fields are not in italics, but
when I merge the document with my list, my merged fields in the new document
are in italics. I have changed the font, but this doesn't help. I have
checked the paragraph markers, and they are not in italics. The list is not
in italics.

Copying the contents of the main document to a new document doesn't help as
all of the controls come with the file.

Please help. I hope I don't have to re-create my main document again.....
 
G

Graham Mayor

Add charformat switches to the merge fields (remove any mergeformat fields
that may be present).
The following macro will do that for you, should you have a lot of fields in
your document.

Sub ChangeSwitch()
Dim oRng As Range
Dim iFld As Integer
Dim strChoice As String

Selection.HomeKey
ActiveDocument.ActiveWindow.View.ShowFieldCodes = True

strChoice = MsgBox("Replace Mergeformat switch with Charformat switch?" _
& vbCr & "Click 'No' to remove formatting switch completely", _
vbYesNoCancel, "Replace Formatting Switch")

If strChoice = 2 Then GoTo UserCancelled

If strChoice = vbYes Then
For iFld = ActiveDocument.Fields.Count To 1 Step -1
With ActiveDocument.Fields(iFld)
If .Type = wdFieldMergeField Then
If InStr(1, .Code, "MERGEFORMAT") <> 0 Then
.Code.Text = Replace(.Code.Text, "MERGEFORMAT",
"CHARFORMAT")
End If
If InStr(1, .Code, "CHARFORMAT") = 0 Then
.Code.Text = .Code.Text & " \* CHARFORMAT "
End If
.Update
End If
End With
Next iFld
End If
If strChoice = vbNo Then
For iFld = ActiveDocument.Fields.Count To 1 Step -1
With ActiveDocument.Fields(iFld)
If .Type = wdFieldMergeField Then
If InStr(1, .Code, "MERGEFORMAT") <> 0 Then
.Code.Text = Replace(.Code.Text, "\* MERGEFORMAT", "")
End If
If InStr(1, .Code, "CHARFORMAT") <> 0 Then
.Code.Text = Replace(.Code.Text, " \* CHARFORMAT ", "")
End If
.Update
End If
End With
Next iFld
End If
ActiveDocument.ActiveWindow.View.ShowFieldCodes = False
Exit Sub

UserCancelled:
MsgBox "User Cancelled", vbInformation, "Replace Formatting Switch"
End Sub

http://www.gmayor.com/installing_macro.htm

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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
P

Peggy Dolter

We are on Word 2002 and experiencing a similar problem. The main document
pulls in fields from the data file (Excel 2002). Based on the main document,
one sentence is supposed to be italicized -- but it's not. It comes out
plain, not italicized. It worked the first few times when I tested the
merge, but it abruptly stopped working then. Any advice or ideas? Thanks
for your time,
 
G

Graham Mayor

The issue and fix are exactly the same for Word 2002.

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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
P

Peggy Dolter

I felt intimidated by the macro solution, so instead, I reorganized the whole
set of letters. Now the fields that are supposed to be italicized are in the
very top main Word document rather than in one of the dependent sub-main Word
documents. This allows them to stay italicized after merging. It is not the
most elegant solution but it works! Thank you for your time and trouble,
 

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