code for adding envelope to document

S

Southern at Heart

I am needing 2 macros to insert an envelope as either a business, or standard
letter size, but I can't get it to work. No matter what I specify in the
height and width, it seems the macro always gives me an envelope the size of
what ever I manually picked the last time I went under envelope options and
changed it. Am I doing something wrong here?
I have two macros, below is one of them I made witht the help of the
recorder. I should add a standard sized letter envelope, but if the last
envelope I manually added to a document was a business envelope, then that's
what will be added with this code. I can't figure this out!

Sub Standard_Envelope()
Dim strAddress As String
Dim object As MSForms.dataObject
Dim Name As Variant
Set object = New dataObject
object.GetFromClipboard
strAddress = object.GetText(1) 'Address copied from Clipboard
Name = Split(strAddress, vbCrLf) 'Copied from Outlook...

ActiveDocument.Envelope.Insert ExtractAddress:=False, OmitReturnAddress:= _
False, PrintBarCode:=False, PrintFIMA:=False,
Height:=InchesToPoints(3.63 _
), Width:=InchesToPoints(6.5), Address:=strAddress, AutoText:= _
"", ReturnAddress:="Me" & vbCrLf & "My street" & vbCrLf & _
"My City, state, zip", ReturnAutoText:= _
"", AddressFromLeft:=wdAutoPosition, AddressFromTop:= _
wdAutoPosition, ReturnAddressFromLeft:=wdAutoPosition, _
ReturnAddressFromTop:=wdAutoPosition, DefaultOrientation:= _
wdCenterLandscape, DefaultFaceUp:=True, PrintEPostage:=False

ChangeFileOpenDirectory _
"C:\Documents and Settings\Me\My Documents\My Office\Word
Items\My Letters\"
ActiveDocument.SaveAs FileName:=Name(0) & ".doc"
End Sub
 
D

Doug Robbins - Word MVP

From the VBA Help file

Size - OptionalVariant - A string that specifies the envelope size. The
string must match one of the sizes listed in the Envelope size box in the
Envelope Options dialog box (for example, "Size 10" or "C4").

Height - OptionalVariant - The height of the envelope, measured in points,
when the Size argument is set to "Custom size."
Width - OptionalVariant - The width of the envelope, measured in points,
when the Size argument is set to "Custom size."

As a result, the Height and Width settings are only effective if the Size is
set to "Custom size". In your case however, you can probably just use

Size:="Size 10"

if that is what "business" or "standard letter" size means to you.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
S

Southern at Heart

Thank you SO MUCH!!!

Doug Robbins - Word MVP said:
From the VBA Help file

Size - OptionalVariant - A string that specifies the envelope size. The
string must match one of the sizes listed in the Envelope size box in the
Envelope Options dialog box (for example, "Size 10" or "C4").

Height - OptionalVariant - The height of the envelope, measured in points,
when the Size argument is set to "Custom size."
Width - OptionalVariant - The width of the envelope, measured in points,
when the Size argument is set to "Custom size."

As a result, the Height and Width settings are only effective if the Size is
set to "Custom size". In your case however, you can probably just use

Size:="Size 10"

if that is what "business" or "standard letter" size means to you.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
D

Doug Robbins - Word MVP

You're welcome.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top