Home

Performing mail merge with an XML file

%3CLINGO-SUB%20id%3D%22lingo-sub-442661%22%20slang%3D%22en-US%22%3EPerforming%20mail%20merge%20with%20an%20XML%20file%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-442661%22%20slang%3D%22en-US%22%3E%3CP%3EMany%20moons%20ago%20I%20played%20around%20with%20peforming%20mail%20merges%20with%20xml%20files%20including%20the%20ability%20to%20handle%20repeating%20information%20in%20a%20table%20within%20the%20document%2C%20but%20now%20when%20I%20look%20for%20documentation%20on%20how%20to%20do%20this%20I'm%20only%20finding%20what%20appear%20to%20be%20out-of-date%20articles.%3C%2FP%3E%3CP%3EAnyone%20have%20good%20references%20for%20how%20do%20do%20this%3F%3C%2FP%3E%3CP%3EI%20also%20seem%20to%20recall%20there%20was%20an%20additional%20tool%20that%20could%20be%20downloaded%20to%20inspect%20and%20match%20the%20merge%20fields%20in%20the%20document%20template%20with%20the%20xml%20fields%20in%20the%20xml%20file.%20Is%20there%20such%20a%20tool%20for%20the%20current%20version%20of%20Word%3F%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3CP%3EPaul%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-546219%22%20slang%3D%22en-US%22%3ERe%3A%20Performing%20mail%20merge%20with%20an%20XML%20file%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-546219%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F4823%22%20target%3D%22_blank%22%3E%40Paul%20O'Flaherty%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20style%3D%22display%3A%20inline%20!important%3B%20float%3A%20none%3B%20background-color%3A%20%23ffffff%3B%20color%3A%20%23333333%3B%20font-family%3A%20'SegoeUI'%2C'Lato'%2C'Helvetica%20Neue'%2CHelvetica%2CArial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3ETo%20handle%20repeating%20information%20in%20a%20table%20within%20the%20document%2C%20u%3C%2FSPAN%3Ese%20the%20Many%20to%20One%20Facility%20on%20my%20Merge%20Tools%20Add-in%20that%20is%20contained%20in%20the%20MERGE%20TOOLS%20ADD-IN.zip%20file%20that%20you%20can%20download%20from%20the%20following%20page%20of%20my%20One%20Drive%3A%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22http%3A%2F%2Fbit.ly%2F1hduSCB%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fbit.ly%2F1hduSCB%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EExtract%20the%20files%20from%20the%20archive%20and%20read%20the%3A%3C%2FP%3E%0A%3CP%3E%E2%80%9CREAD%20ME%20%E2%80%93%20Setting%20up%20and%20using%20the%20Merge%20Tools%20Add-in.pdf%3C%2FP%3E%0A%3CP%3Eto%20see%20how%20to%20install%20and%20use%20the%20various%20tools.%20Using%20those%20tools%2C%20it%20is%20possible%20to%20perform%20the%20following%20types%20of%20merge%20that%20cannot%20be%20done%20with%20Mail%20Merge%20%E2%80%9Cout-of-the-box%E2%80%9D%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EMerge%20to%20e-mail%20messages%20either%20with%20or%20without%20attachments%2C%20with%20the%20documents%20created%20by%20the%20merge%20being%20sent%20as%20either%20Word%20or%20PDF%20attachments%20or%20as%20the%20body%20of%20the%20e-mail%20message.%3C%2FLI%3E%0A%3CLI%3EMerge%20to%20individual%20documents%20in%20either%20Word%20or%20PDF%20format%20with%20the%20filenames%20being%20supplied%20by%20the%20data%20in%20one%20of%20the%20fields%20in%20the%20data%20source%3C%2FLI%3E%0A%3CLI%3EMany%20to%20One%20type%20merges%2C%20which%20can%20be%20used%20for%20creating%20documents%20such%20as%20invoices%20where%20there%20are%20multiple%20records%20in%20the%20data%20source%20that%20have%20common%20data%20in%20one%20of%20the%20fields%3C%2FLI%3E%0A%3CLI%3EMerging%20to%20a%20document%20that%20will%20include%20a%20chart%20that%20is%20unique%20to%20each%20record%20in%20the%20data%20source%3C%2FLI%3E%0A%3CLI%3EMerging%20a%20document%20with%20Content%20Controls%3C%2FLI%3E%0A%3CLI%3EMerging%20a%20document%20that%20contains%20Legacy%20FormFields%3C%2FLI%3E%0A%3CLI%3EDuplex%20Merges%3C%2FLI%3E%0A%3CLI%3EMerging%20to%20a%20printer%20that%20will%20collate%20and%20staple%20the%20output%20created%20from%20each%20record%20in%20the%20data%20source.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EThe%20requirements%20for%20using%20the%20system%20are%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EThe%20mail%20merge%20main%20document%20must%20be%20of%20the%20Letters%20type%2C%20though%20that%20does%20not%20mean%20that%20the%20output%20cannot%20be%20sent%20as%20an%20e-mail%20message%20where%20relevant.%3C%2FLI%3E%0A%3CLI%3EFor%20the%20Many%20To%20One%2C%20Merge%20with%20Attachments%20and%20Merge%20to%20Individual%20Docs%20utilities%2C%20the%20data%20source%20may%20be%20either%20a%20table%20or%20query%20in%20an%20Access%20database%2C%20or%20in%20the%20form%20of%20an%20Excel%20worksheet%20and%20that%20worksheet%20must%20be%20the%20first%20sheet%20in%20the%20Excel%20workbook.%20If%20the%20data%20is%20on%20some%20other%20sheet%2C%20you%20can%20easily%20move%20that%20sheet%20so%20that%20it%20is%20the%20first%20sheet%20in%20the%20workbook%20by%20clicking%20on%20the%20sheet%20tab%20and%20dragging%20it%20to%20the%20left.%20For%20the%20Chart%20Merge%20utility%2C%20see%20the%20Mail%20Merging%20with%20Charts%20document%20that%20is%20included%20in%20the%20Merge%20Tools%20Add-in%20Zip%20file%20for%20additional%20requirements%20for%20the%20data%20source%20for%20use%20with%20that%20utility%3C%2FLI%3E%0A%3CLI%3EFor%20a%20data%20source%20in%20the%20form%20of%20an%20Excel%20worksheet%2C%20the%20field%20names%20must%20be%20in%20the%20first%20row%20of%20the%20worksheet%20and%20there%20must%20be%20a%20field%20name%20in%20all%20of%20the%20cells%20in%20that%20row%20that%20are%20within%20the%20range%20of%20columns%20that%20contain%20the%20data.%3C%2FLI%3E%0A%3CLI%3EFor%20both%20types%20of%20data%20source%2C%20the%20field%20names%20must%20contain%20only%20alphanumeric%20characters%20(No%20%40%2C%23%2C%24%2C%25%2C%26amp%3B%2C(%2C)%2C%20etc)%20and%20the%20field%20names%20must%20not%20start%20with%20a%20numeric%20character%20(0-9).%20The%26nbsp%3Bnumber%20of%20characters%20in%20the%20field%20names%2C%20including%20spaces%2C%20must%20not%20be%20more%20than%2040%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Paul O'Flaherty
Senior Member

Many moons ago I played around with peforming mail merges with xml files including the ability to handle repeating information in a table within the document, but now when I look for documentation on how to do this I'm only finding what appear to be out-of-date articles.

Anyone have good references for how do do this?

I also seem to recall there was an additional tool that could be downloaded to inspect and match the merge fields in the document template with the xml fields in the xml file. Is there such a tool for the current version of Word?

Thanks

Paul

1 Reply

@Paul O'Flaherty 

 

To handle repeating information in a table within the document, use the Many to One Facility on my Merge Tools Add-in that is contained in the MERGE TOOLS ADD-IN.zip file that you can download from the following page of my One Drive:

http://bit.ly/1hduSCB

Extract the files from the archive and read the:

“READ ME – Setting up and using the Merge Tools Add-in.pdf

to see how to install and use the various tools. Using those tools, it is possible to perform the following types of merge that cannot be done with Mail Merge “out-of-the-box”:

  • Merge to e-mail messages either with or without attachments, with the documents created by the merge being sent as either Word or PDF attachments or as the body of the e-mail message.
  • Merge to individual documents in either Word or PDF format with the filenames being supplied by the data in one of the fields in the data source
  • Many to One type merges, which can be used for creating documents such as invoices where there are multiple records in the data source that have common data in one of the fields
  • Merging to a document that will include a chart that is unique to each record in the data source
  • Merging a document with Content Controls
  • Merging a document that contains Legacy FormFields
  • Duplex Merges
  • Merging to a printer that will collate and staple the output created from each record in the data source.

The requirements for using the system are:

  • The mail merge main document must be of the Letters type, though that does not mean that the output cannot be sent as an e-mail message where relevant.
  • For the Many To One, Merge with Attachments and Merge to Individual Docs utilities, the data source may be either a table or query in an Access database, or in the form of an Excel worksheet and that worksheet must be the first sheet in the Excel workbook. If the data is on some other sheet, you can easily move that sheet so that it is the first sheet in the workbook by clicking on the sheet tab and dragging it to the left. For the Chart Merge utility, see the Mail Merging with Charts document that is included in the Merge Tools Add-in Zip file for additional requirements for the data source for use with that utility
  • For a data source in the form of an Excel worksheet, the field names must be in the first row of the worksheet and there must be a field name in all of the cells in that row that are within the range of columns that contain the data.
  • For both types of data source, the field names must contain only alphanumeric characters (No @,#,$,%,&,(,), etc) and the field names must not start with a numeric character (0-9). The number of characters in the field names, including spaces, must not be more than 40

.

Related Conversations
Extentions Synchronization
Deleted in Discussions on
3 Replies
Tabs and Dark Mode
cjc2112 in Discussions on
36 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies