fullnoob.blogg.se

How to do a mail merge microsoft word 2016
How to do a mail merge microsoft word 2016










how to do a mail merge microsoft word 2016
  1. #How to do a mail merge microsoft word 2016 install
  2. #How to do a mail merge microsoft word 2016 code

'When the mail merge is complete, 1) make Word visible, Private Sub oApp_MailMergeAfterMerge(ByVal Doc As Word.Document, ByVal DocResult As Word.Document) MailMerge.Destination = wdSendToNewDocument 'Perform the mail merge to a new document. OSel.TypeText " This letter is to inform you." 'Add the field codes to the document to create the form letter. SDBPath = "C:\Program Files\Microsoft Office\" & _

how to do a mail merge microsoft word 2016

'Set up the mail merge data source to Northwind.mdb. 'Start a new main document for the mail merge. Set oApp = CreateObject("Word.Application") Note If it is necessary, modify the path to Northwind.mdb to match your installation for Office XP.

how to do a mail merge microsoft word 2016

#How to do a mail merge microsoft word 2016 code

Note To use the Microsoft Office Word 2003 Object, add the Microsoft Word 11.0 Object Library in the list of references and then Click OK.Īdd the following code to the code module for Form1. By default, Form1 is created.Ĭlick Microsoft Word 2000 Object Library in the list of references, and then click OK. Start a new Standard EXE project in Visual Basic.

#How to do a mail merge microsoft word 2016 install

On the Help menu, click Sample Databases, and then choose Northwind Sample Database to install this feature. If Northwind is not installed, start Microsoft Access 2002 or Microsoft Office Access 2003. The data source that is used is the sample Access database Northwind.mdb. 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= ", _

how to do a mail merge microsoft word 2016

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. For a complete description of each argument, refer to the Microsoft Word Visual Basic online Help.












How to do a mail merge microsoft word 2016