ExportRecipientList Method

MailMerge.ExportRecipientList Method

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

Version Information
 Version Added:  Publisher 2007

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
pbAsCsvFile

1

Save as comma-delimited CSV file.

pbAsMdbFile

0

Save 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 Office 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.

Visual Basic for Applications
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



Show:
© 2016 Microsoft