Envelope Object

See Also         Properties         Methods        

Documents collection (Document object)
Envelope object
Multiple objects

Represents an envelope. There is no Envelopes collection; each Document object contains only one Envelope object.

Using the Envelope Object

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 hasn't 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 hasn't 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.