Attachments.ClearAll method (Publisher)

Clears (deletes) all the Attachment objects in the parent Attachments collection of an email merge message.

Syntax

expression.ClearAll

expression A variable that represents an Attachments object.

Remarks

To clear an individual attachment, use the Delete method of the specific Attachment object.

Example

The following Microsoft Visual Basic for Applications (VBA) macro shows how to clear all the attachments to the message in an email merge. The code prints the number of current attachments to the message in the Immediate window and then deletes all of the Attachment objects in the collection.

Public Sub ClearAll_Example() 
 
 Dim pubAttachments As Publisher.Attachments 
 
 Dim pubMailMerge As Publisher.MailMerge 
 Dim pubEmailMergeEnvelope As Publisher.EmailMergeEnvelope 
 
 Set pubMailMerge = ThisDocument.MailMerge 
 Set pubEmailMergeEnvelope = pubMailMerge.EmailMergeEnvelope 
 Set pubAttachments = pubEmailMergeEnvelope.Attachments 
 
 Debug.Print pubAttachments.Count 
 pubAttachments.ClearAll 
 
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.