How to preserve formatting in MS Word MailMerge ?

I am doing a mailmerge using MS Word 2013. I have a table in an MS Word 2013 file with entries, and a few words have simple formatting (e.g. italics or bold). I want to merge to a new directory (e.g. one or two pages with all the table entries), but when I do this, the formatting is lost, and everything comes out roman (non-italic) characters.
In the mailmerge document, I have tried
MERGEFIELD "Question" \* MERGEFORMAT
and
MERGEFIELD "Question" \* CHARFORMAT
with the same results: no italics or bold.

Is there a way I can create the merge I want?

Thank you.
Lev SeltzerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SimonCommented:
Use charformat and while displaying the field codes, format the first character of the field in your desired style.

{MERGEFIELD "Question" \* CHARFORMAT} = print in bold italic when merged.

The best reference I've found on this issue is
www.gmayor.com/formatting_word_fields.htm
0
Lev SeltzerAuthor Commented:
THank you for your response, but this is not quite what I mean

I have a list in file data.docx. Let's say it looks like this:
FRUIT
Apples
Oranges
Pears

In my really simple merge, I simply want to duplicate this list. I want apples to be BOLD, oranges to be italic and Pears to be neither bold nor italic.

I am not trying to preserve any other aspect of the formatting (e.g. not the font name or size), but I could still manage if all this information copied over.

Does this make sense now?

Thank you.
0
SimonCommented:
I see. If your table includes a separate column with a formatting code in, you could use nested mailmerge {IF} statements to conditionally format the merged version similar to this
{IF FormatCode="BI" "{mergefield Fruit \Charformat}"  {IF FormatCode="B" "{mergefield Fruit \Charformat}" "....} }

But if your table doesn't already contain that format code indicator (B, I, BI...) then  ithink you'd need to add it, or use VBA code to examine each table element and output that "Format Code".

Overall it makes me think that mailmerge isn't the tool for the job.
0
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Lev SeltzerAuthor Commented:
Your suggestion sounds like it could work in different situations, but not mine. My example (above) was really simple, but in fact I have several words in each field, forming a sentence or two, and most words are roman type, and a few words are bold or italic.

You seem to be saying at the end that MS Word MailMerge will ignore the formatting of the source database? I know in my case I can cut and paste the information into a new document, but I was really hoping to use the merge feature, as future merges will be getting more complicated.

THank you.
0
GrahamSkanRetiredCommented:
I don't believe that the ability to transfer the formatting was ever in MailMerge. I tried using DDE instead of ODBC, but it had no effect.

What you could do is to run a couple of macros. The first one would be on the datasource document to add markup characters to the bold or italic text.
Sub Markup()
    With ActiveDocument
    'Find in tables can be buggy, so convert to text
        .Bookmarks.Add "bmkTable", .Tables(1).Range
        .Tables(1).ConvertToText vbTab
    End With
    'markup bold words
    With ActiveDocument.Range.Find
        .MatchWildcards = True
        .Text = "(<*>)"
        .Font.Bold = True
        .Replacement.Text = "<b>\1<@@@b>" 'cannot do "<b>\1<\b>": it doesn't like "\b"
        .Execute Replace:=wdReplaceAll
     End With
            
    'markup italic words
    With ActiveDocument.Range.Find
        .MatchWildcards = True
         .Text = "(<*>)"
        .Font.Italic = True
        .Replacement.Text = "<i>\1<@@@i>"
        .Execute Replace:=wdReplaceAll
    End With
     'change "@@@" to "\" as originally intended
    With ActiveDocument.Range.Find
        .MatchWildcards = False
        .Text = "@@@"
        .Replacement.Text = "\"
        .Execute Replace:=wdReplaceAll
    End With
    'recreate the table
    ActiveDocument.Bookmarks("bmkTable").Range.ConvertToTable vbTab
End Sub

Open in new window

The second would run on the result document to convert the markups to formatting:
Sub FormatFont()
    With ActiveDocument.Range.Find
        .MatchWildcards = True
        .Text = "\<b\>([A-z ]{1,})\<\\b\>"
        .Replacement.Font.Bold = True
        .Replacement.Text = "\1"
        .Execute Replace:=wdReplaceAll
    End With
    With ActiveDocument.Range.Find
        .MatchWildcards = True
        .Text = "\<i\>([A-z ]{1,})\<\\i\>"
        .Replacement.Font.Italic = True
        .Replacement.Text = "\1"
        .Execute Replace:=wdReplaceAll
    End With
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Lev SeltzerAuthor Commented:
GrahamSkan: Thank you for doing more research. I haven't done mailmerge in a while, and instead have been working with MSSQL databases that contain formatted website content and displaying the formatted page content using programming - I remembered incorrectly that I could do this simple task also in mailmerge.

I will try your macros shortly.

Thank you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.