Table of contents
TOC
Collapse the table of content
Expand the table of content

MailMerge.OpenDataSource Method (Publisher)

office 365 dev account|Last Updated: 8/24/2017
|
3 Contributors

Attaches a data source to the specified publication, which becomes a main publication if it is not one already.

Syntax

expression. OpenDataSource( bstrDataSource, bstrConnect, bstrTable, fOpenExclusive, fNeverPrompt)

_expression_A variable that represents a MailMerge object.

Parameters

NameRequired/OptionalData TypeDescription
bstrDataSourceOptionalStringThe data source path and file name. You can specify a Microsoft Query (.qry) file instead of specifying a data source, a connection string, and a table name string; values in a Microsoft Query file override values for bstrConnect and bstrTable.
bstrConnectOptionalStringA connection string.
bstrTableOptionalStringThe name of the table in the data source.
fOpenExclusiveOptionalLongTrue to deny others access to the database. False allows others read/write permission to the database. The default value is False.
fNeverPromptOptionalLongLong. True never prompts when opening the data source. False displays the Data Link Properties dialog box. The default value is False.

Remarks

Note If you are using a data source for mail merge, you must add a catalog merge area to the publication page before you attach to the data source.

Example

This example attaches a table from a database and denies everyone else write access to the database while it is opened.

For this example to run properly, you must replace PathToFile with a valid file path and TableName with a valid data source table name.

Sub AttachDataSource() 

    ActiveDocument.MailMerge.OpenDataSource _ 
        bstrDataSource:="PathToFile",  _ 
        bstrTable:="TableName", _ 
        fNeverPrompt:=True, fOpenExclusive:=True 

End Sub
© 2018 Microsoft