Mail Merge using Word 2010 - Header source file is not being used instead it is using first record from datasource

Posted on 2011-10-06
Last Modified: 2012-05-12
I am in the process of converting mail merge documents from .doc(word 2003-2007 format) to .docx format (word 2010). I open the .doc and click convert then save it as a .docx. It seems that the .docx file doesn't recognize that theres a header file anymore and instead it is using the first record in the datasource as the header and datasource. There is only one row in the datasource and the header source is in a table as suggested by microsoft.

Example: I have both versions open and go to the mail merge helper. I view the datasource in both.
Owner_Name: Jon Doe
Organization: Some company
Jon_Doe: Jon Doe
Some_Company: Some company

As you can see the header file isn't being recognized correctly in the .docx. Weird part is that if I relink the header file I can preview all the data correctly. But when I save it and re-open it, it doesn't recognize the header again and the data is still screwed up. I have tried this both on a network and on my desktop and I experience the same results.

Note: the header source is a doc(also tried it as a.docx) and the data source is a text file.

Thanks in advance.
Question by:dgoodheart
    LVL 22

    Expert Comment

    by:Brian B (TBone2K)
    I'm not able to reproduce the problem in a "normal" document. Maybe something is corrupted. Copy just the table contents (not the whole document) to a new document and try that.

    Author Comment

    I tried copying the contents of the header document first into notepad (to get rid of formatting) and then into a word docx and converted it to a table. I used the same datasource as that is the one thing I am not able to change. I then created a new mail merge document (form letter) and added the merge fields into it. I was able to preview the results and everything worked correctly. After saving then closing/reopening the document exhibits the same behavior as before doesn't use the header.

    When you tried to reproduce the problem did you use a txt file for the datasource?

    This is my header is string form:

    Owner_Name      Owner_Organization      Owner_Address1      Owner_Address2      Owner_Address3      Owner_Address4      Owner_Address5      Owner_Address6      Phone1      Phone2      File_Number      Description      Issued      Expiry      RefNumber      UserName      FeeAmount      Info2046      Info2122      Info2047      Info2053      Info2044      Info2042      Info2043      Info2045      sysdate

    This is my test datasource txt file:

     John Doe             555 TEST ST      TEST                                  () -       () -       111111111111             Tuesday, September 27, 2011      Saturday, December 31, 2011      test 2011      ADMIN       22      something       DHC      Yes      12345432      Something else       5      3      3      Another Datetime
    LVL 22

    Expert Comment

    by:Brian B (TBone2K)
    Hi again and sorry for the delay.

    The problem is that it sounds to me like your datasource is the problem. Can you not copy some of the data (not just the headers) over to a new document for test purposes?

    Author Comment

    Hey TBone2k,

    I have tried copying the data into a new txt document and copying the headers into a new docx document then linking them both to a new mail merge form letter, but I keep getting the same results. I will attach some sample documents to this post that should replicate my problem.

    If you take a look at the mail merge helper (not normally on the toolbar) you can see that when the document is loaded that the datasource doens't use the headers correctly. But when you relink the header file everything works as expected.

    Thanks for the follow up. mydatasource.txt mydocument.docx myheader.docx
    LVL 22

    Expert Comment

    by:Brian B (TBone2K)
    Thanks for the sample data. I will try and have a look later today.
    LVL 22

    Accepted Solution

    Okay, I was able to get this to work by using a macro:
    Public Sub Document_Open()

    With ActiveDocument.MailMerge
        .MainDocumentType = wdFormLetters
        .OpenHeaderSource Name:="c:\mailmergetest\myheader.docx", Revert:=False, AddToRecentFiles:=False, ConfirmConversions:=False, ReadOnly:=True
        .OpenDataSource Name:="C:\mailmergetest\mydatasource.txt", ConfirmConversions:=False
    End With
    ActiveDocument.ActiveWindow.View.MailMergeDataView = True

    End Sub

    Not the prettiest way of doing this, but it seems to work. MS seems to be moving away from this feature, becuase there aren't even buttons for setting this up built in to Word. You could probably do the same thing without a macro, but I had to customize the ribbon, add another group to the mailings ribbon, and add buttons for "Mail Merge Create Header Source" and "Mail Merge Open Header Source" in order to define the header source.

    In the end I was able to add another line ot the data source, and open and close the document and it continues to work and show the new data.

    Author Closing Comment

    Thanks for all your help. With this I am able to use the new format and everything works correctly.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
    Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
    This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
    This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now