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

MailMerge.ExportRecipientList Method (Publisher)

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

Exports the list of mail-merge recipients to a Microsoft Office Access (.mdb) file or to a comma-delimited text (.csv) file.

Syntax

expression. ExportRecipientList( Filename, FileType, IncludedOnly)

_expression_A variable that represents a MailMerge object.

Parameters

NameRequired/OptionalData TypeDescription
FilenameRequiredStringThe name of the file that will contain the list of recipients.
FileTypeOptionalPbRecipientListFileTypeThe type of file to save. See Remarks for possible values.
IncludedOnlyOptionalBooleanWhether to restrict entries in the recipient list to specific recipients.

Remarks

Possible values for the FileType parameter include the following constants from the PbRecipientListFileType enumeration:

ConstantValueDescription
pbAsCsvFile1Save as comma-delimited CSV file.
pbAsMdbFile0Save as Microsoft Office Access MDB file.

The ExportRecipientList method corresponds to the Export recipient list to new file command in the E-mail Merge and Mail Merge task panes in the Microsoft Publisher user interface.

Example

The following Microsoft Visual Basic for Applications (VBA) macro shows how to use the ExportRecipientList method to export the list of mail-merge recipients to an Access database file. Before running this macro, ensure that the active document is connected to a data source. If the active document is not already connected to a data source, you can use the ** MailMerge.OpenDataSource** method to make the connection.

Also, before running the code, replace username in the folder path to the saved file with the name of a valid user on your computer, or replace the folder path and file name with a path and file name of your choice.

Note that the folder path used in this example is typical of folder paths in Microsoft Windows Vista. You must have permission to save files in the folder you designate.

Public Sub ExportRecipientList_Example() 

 Dim pubMailMerge As Publisher.MailMerge 

 Set pubMailMerge = ThisDocument.MailMerge 
 pubMailMerge.ExportRecipientList "C:\Users\username\Documents\My Data Sources\MyAddressList", pbAsMdbFile, True 

End Sub
© 2018 Microsoft