none
mail merge manually with a header and source document RRS feed

  • Question

  • using Office 2010 and up

    once upon a time when merging with word you could specify a header and data document (as described here)

    I still have code that does this programmatically with

    //open the template
    mrgDoc = wrdApp.Documents.Add(pathToTemplate, ref oMissing, ref oMissing, ref oMissing);
    
    //open the data file
    mrgDoc.MailMerge.OpenHeaderSource(pathToHdr);
    mrgDoc.MailMerge.OpenDataSource(pathToDB);

    but I recently had an issue where the merging wasn't happening correctly.  I've since fixed that,  but the whole process would have been a lot easier if I could have manually performed this merge with Word 2010, but I don't see any way to do this anymore.

    Was this removed?  Can I still merge with a text document as outlined in the link above?


    Thank Kevin

    Thursday, January 23, 2014 8:56 PM

Answers

  • A key fact about header sources in recent versions of Windows Word is that when you save in Office Open XML format (e.g. .docx), Word will, at best, end up ignoring any HeaderSource. In fact, I thought that in one version, Word would actually crash if the headerSource element was present.

    Unfortunately, Word 2010 does not completely ignore a HeaderSource - if one is specified in a format it can understand, Word may still pop up its delimiters dialog box, and then ignore the header, by which I mean that it will take the first row of the data source as the header, and you will lose a data row. Even if you use the old workaround of doubling up the header row to avoid the delimiter prompt, Word ignores the header.

    (If you search for [MS-OI29500] you'll find the MS document where the info. about headerSource is provided. It is possible that what Word does depends on whether the .docx is in compatibility mode or not - I don't know.

    But if you save in Word 97-2003 .doc format, Word still recognses some types of header source.

    If you need .docx I think you really just have to stick to using data sources that have either a real header row (e.g. a header row in a plain text file), or some mechanism to define a header (possibly via a schema.ini file), or have a logical header row (e.g. a table in Access). 


    Peter Jamieson

    • Marked as answer by kevcoder Sunday, January 26, 2014 9:44 PM
    Friday, January 24, 2014 4:22 PM

All replies

  • Non-programming questions should be posted to an end-user forum, rather than on MSDN. You'll find a lot more people there who can help you:

    http://answers.microsoft.com/en-us/office/forum/word


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, January 24, 2014 2:59 PM
    Moderator
  • A key fact about header sources in recent versions of Windows Word is that when you save in Office Open XML format (e.g. .docx), Word will, at best, end up ignoring any HeaderSource. In fact, I thought that in one version, Word would actually crash if the headerSource element was present.

    Unfortunately, Word 2010 does not completely ignore a HeaderSource - if one is specified in a format it can understand, Word may still pop up its delimiters dialog box, and then ignore the header, by which I mean that it will take the first row of the data source as the header, and you will lose a data row. Even if you use the old workaround of doubling up the header row to avoid the delimiter prompt, Word ignores the header.

    (If you search for [MS-OI29500] you'll find the MS document where the info. about headerSource is provided. It is possible that what Word does depends on whether the .docx is in compatibility mode or not - I don't know.

    But if you save in Word 97-2003 .doc format, Word still recognses some types of header source.

    If you need .docx I think you really just have to stick to using data sources that have either a real header row (e.g. a header row in a plain text file), or some mechanism to define a header (possibly via a schema.ini file), or have a logical header row (e.g. a table in Access). 


    Peter Jamieson

    • Marked as answer by kevcoder Sunday, January 26, 2014 9:44 PM
    Friday, January 24, 2014 4:22 PM