[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


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
Medium Priority
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
  • 4
  • 3
LVL 25

Expert Comment

by:Brian B
ID: 36931026
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

ID: 36931267
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 25

Expert Comment

by:Brian B
ID: 36968660
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?
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


Author Comment

ID: 36981637
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 25

Expert Comment

by:Brian B
ID: 36986511
Thanks for the sample data. I will try and have a look later today.
LVL 25

Accepted Solution

Brian B earned 2000 total points
ID: 36987857
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

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Do you ever need to create a 20 page Word document for some testing purpose? Are you tired of copying & pasting old boring "lorem ipsum" text over and over again, increasing font size and line space in order to make the document 20+ pages long? Look…
Lost Word File? Eagerly, need it back? Read ahead; this File Recovery guide is for you.
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.

873 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