Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Built-in Dialog box wdDialogToolsCreateEnvelope 1

Status
Not open for further replies.

grannyM

Programmer
Nov 26, 2002
39
0
0
US
We have a macro to create envelopes by pulling information from our databases. There are several options, but basically they all end with:

Code:
    With Dialogs(wdDialogToolsCreateEnvelope)
        .Addrtext = temp$
        .Show
    End With

We use pre-printed envelopes and on one of the options I want to add an Identification number that will print below the pre-printed return address. I have tried to edit the code to:

Code:
    With Dialogs(wdDialogToolsCreateEnvelope)
        .Addrtext = temp$
        .EnvOmitReturn = False
        .RetAddrFromTop = 1.75
        .RetAddrFromLeft = 1.5
        .Retaddrtext = "Ref:  " & RefNo$
        .Show
    End With

The mailing address still works, but nothing shows in the return address field. Thanks for any help you can give.
 
Hi grannyM,

I hate using built-in dialogs because there is no proper documentation on them and they don't work properly - you can't really say they don't work as advertised because they aren't really advertised.

With your case here, the Return Address seems to work if you use [blue].EnvReturn[/blue] instead of [purple]RetAddrText[/purple].

The [purple]RetAddrFromTop[/purple] and [purple]RetAddrFromLeft[/purple] properties are another matter. They appear to be the right properties in that querying them gives whatever value they previously had, and setting them changes the values returned by the properties, BUT that does not get reflected on the Shown Dialog. All I can guess is that the settings behind the Options button somehow get set back to the previous values as part of the processing of the Show method. I can't see any effective way to control them from code and suggest you address the envelope object directly instead ..

Code:
[blue]ActiveDocument.Envelope.Insert
With ActiveDocument.Envelope
    .ReturnAddressFromTop = CentimetersToPoints(1.75)
    .ReturnAddressFromLeft = CentimetersToPoints(1.5)
End With
With Dialogs(wdDialogToolsCreateEnvelope)
        .Addrtext = temp$
        .EnvOmitReturn = False
        .EnvReturn = "Ref:  " & RefNo$
        .Show
End With[/blue]

A couple of points about this:
1. I have changed your values from points to centimetres as that seemed to make more sense.
2. If you only want to make temporary changes you may need to add code to save the original values and set them back afterwards.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at [url=http://www.vbaexpress.
 
Thank you Tony!

The .EnvReturn was the key! As for the .RetAddrFromTop and .RetAddrFromLeft, they work on the final printed envelope, which is what we wanted. We do not want to create a document or add an envelope to a document, so I couldn't use first part of your code.

You have been a great help! Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top