

The following sample code creates and executes a mail merge for form letters by using OLEDB (by way of ODSO). To specify DDE as the data access method with OpenDataSource, supply the path and the file name to the database or the workbook for the Name argument, and wdMergeSubTypeWord2000 for the SubType argument.

You can use DDE to access data in Microsoft Access databases or Microsoft Excel workbooks. SQLStatement:= "Select au_id, au_lname, au_fname from authors", _ To specify ODBC as the data access method with OpenDataSource, supply an empty string for the Name argument, an ODBC connection string for the Connection argument, and wdMergeSubTypeWord2000 for the SubType argument.Ĭonnection:= "DSN=MySQLServerDSN DATABASE=pubs uid=sa pwd= ", _ You can use ODBC for your mail merge to access data for which a user data source name (DSN) has been set up on the system. ODSO ignores any information in the Connection argument. ODSO requires that the Name argument for OpenDataSource be either a complete path to a database or a complete path to a valid ODC file. ODSO is the only mechanism by which Word can access data by using OLEDB for a mail merge. Word and other Office XP applications use the Office DataSource Object (ODSO) for OLEDB access to external data sources. OpenDataSource Name:="C:\MyDataSource.odc", _ If you provide a database for the Name argument, Word will automatically use OLEDB if there is an OLEDB provider installed that supports the database format.Įxample. To specify OLEDB as the data access method with OpenDataSource, supply the Name argument with the path and the file name to either the database or an Office DataSource Connection (.odc). OLEDB is the recommended data access method. Different combinations of these three arguments represent different data access methods for the mail merge. Of primary interest for connecting to an external data source are the Name, Connection, and SubType arguments. You can actually request this information from an external system with the help of another Power Automate (Microsoft Flow) action.For a complete description of each argument, refer to the Microsoft Word Visual Basic online Help. This is information about a sample employee. In the second parameter, we specified data in JSON format that will be used to fill merge fields. In the first parameter ‘DOCX document content’ we specified file content of the source document from the output of the previous action. This is an action from Plumsail Documents connector. You can use any other connector to get files from your system. You just specify SharePoint site URL and path to your file.

This action gets file content of the specified file from a SharePoint document library. We use “Manually trigger a flow” trigger here to simplify the Flow. For example, you can start Flow on file creation in a SharePoint document library. Here is the step by step description for the flow. Now we need to create a Power Automate (Microsoft Flow) that will get the source document from the SharePoint document library, fill merge fields in this document and save result document back to the document library.

Please follow this instruction to prepare your source document. The resulting document will be stored back to SharePoint document library.įirstly, we have to prepare the source file with merge fields. Our Flow will get a source document from a SharePoint document library, generate a new document based on source document and on some data. In this example, we will store our documents in SharePoint. Power Automate (Microsoft Flow) has a lot of connectors for different systems. Our source document with merge fields and result document has to be stored somewhere. This approach allows you to create simple DOCX template with merge fields and generate new documents by filling those fields.
#AUTOMATE MAIL MERGE FROM EXCEL HOW TO#
This article demonstrates how to fill merge fields in a DOCX Word document with the help of Power Automate (Microsoft Flow).
