MailMerge.ExportRecipientList method (Publisher)
Exports the list of mail-merge recipients to a Microsoft Office Access (.mdb) file or to a comma-delimited text (.csv) file.
expression.ExportRecipientList(FileName, FileType, IncludedOnly)
expression A variable that represents a MailMerge object.
|Filename||Required||String||The name of the file that will contain the list of recipients.|
|FileType||Optional||PbRecipientListFileType||The type of file to save. See Remarks for possible values.|
|IncludedOnly||Optional||Boolean||Whether to restrict entries in the recipient list to specific recipients.|
Possible values for the FileType parameter include the following constants from the PbRecipientListFileType enumeration:
|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 Email Merge and Mail Merge task panes in the Microsoft Publisher user interface.
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
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.