title | keywords | f1_keywords | api_name | ms.assetid | ms.date | ms.localizationpriority | ||
---|---|---|---|---|---|---|---|---|
Attachments.ClearAll method (Publisher) |
vbapb10.chm569350 |
|
|
ae4e4c60-56cb-f97b-06f4-bd0d2abac4ee |
06/05/2019 |
medium |
Clears (deletes) all the Attachment objects in the parent Attachments collection of an email merge message.
expression.ClearAll
expression A variable that represents an Attachments object.
To clear an individual attachment, use the Delete method of the specific Attachment object.
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
[!includeSupport and feedback]