Mail Merge multiple ID

2020-05-03 10:19发布

问题:

I have data in excel, like below:

and, i have microsoft Word document, like below:

How to mail merge in microsoft word, one to Many row?

I want result like below in microsoft Word:

Thank You Very Much

回答1:

This can be done, but it's a bit complex. There are a number of possible approaches, outlined at my website.

Since you show the desired result as a table, using a Database field is probably the optimal way to go about it. Insert Database is an old command that's no longer exposed in the Word UI by default. You'll find it in File/Options/Customize Ribbon or Quick Access Toolbar, under All Commands.

The command inserts a field with the name Database, via a set of dialog boxes:

  1. Get Data is the same as what you see in mail merge when selecting the data source. This uses any valid connection method (these days, ODBC or OLE DB - the latter is the default) to bind to the data source. Select the data source containing the "many" information. (Note: the "one" side should be only the unique "one" information; the "many" side should be in a separate data source containing the unique identifier from the "one" side for each item on the "many" side.)

  2. Query options is for setting Query Options (filter/sort what comes in). On the left side of the "equation" you need to select the field that is the identifier in the data source for the one side of one-to-many. On the right side, enter a value you know is in the data so that there's a match.

  3. Table AutoFormat can be used to select a built-in (or user-defined) Table Style.

  4. Insert Data - This is important: activate the checkbox Insert Data as field. This is what will dynamically link the data to the data source and provide a link to the merge information.

  5. OK to insert the data / field.

  6. Press Alt+F9 to view the underlying field codes.

  7. Locate the query information (Select...) near the end of the field code. Change the right side of the Where clause to match the mergefield that provides the "one" side of one-to-many. For example: WHERE ((ID= 1)) would become WHERE ((ID= { Mergefield ID }))

  8. If you don't want to see some of the fields (columns), such as an ID column (the "one" side of one-to-many), edit the list of fields at the beginning of the Select statement.

The result will look something like the following