Envelope object (Word)
Represents an envelope attached to a document.
Remarks
Use the Envelope property to return the Envelope object. The following example adds an envelope to a new document and sets the distance between the top of the envelope and the address to 2.25 inches.
Set myDoc = Documents.Add
addr = "Michael Matey" & vbCr & "123 Skye St." _
& vbCr & "Redmond, WA 98107"
retaddr = "Cora Edmonds" & vbCr & "456 Erde Lane" & vbCr _
& "Redmond, WA 98107"
With myDoc.Envelope
.Insert Address:=addr, ReturnAddress:=retaddr
.AddressFromTop = InchesToPoints(2.25)
End With
Remarks
The Envelope object is available regardless of whether an envelope has been added to the specified document. However, an error occurs if you use one of the following properties when an envelope has not been added to the document: Address, AddressFromLeft, AddressFromTop, FeedSource, ReturnAddress, ReturnAddressFromLeft, ReturnAddressFromTop, and UpdateDocument.
The following example demonstrates how to use the On Error GoTo statement to trap the error that occurs if an envelope has not been added to the active document. If, however, an envelope has been added to the document, the recipient address is displayed.
On Error GoTo ErrorHandler
MsgBox ActiveDocument.Envelope.Address
ErrorHandler:
If Err = 5852 Then MsgBox _
"Envelope is not in the specified document"
Use the Insert method to add an envelope to the specified document. Use the PrintOut method to set the properties of an envelope and print it without adding it to the document.
Note
There is no Envelopes collection; each Document object contains only one Envelope object.
See also
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.