Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2007

Tip: Looking for answers? Try searching our database.

HDI: retain envelope format settings?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
C Hayes - 26 Oct 2007 17:37 GMT
I accidently posted this under forms.  sorry.

How do I retain envelope format settings?

I'm having trouble retaining my envelope format settings. When I run the
macro it does not retain the formating from the ('set the envelope style)
section.

Sub printenvelope()
'instantiate the envelope
Dim mydoc As Document
Dim myenvelope As Envelope
Set mydoc = ActiveDocument
Set myenvelope = mydoc.Envelope

'set the envelope style
With myenvelope.AddressStyle
.Font.Name = "Arial"
.Font.Size = 12
.ParagraphFormat.Space1
.ParagraphFormat.LineUnitAfter = 0
.ParagraphFormat.LineUnitBefore = 0
End With

'print the envelope out
myenvelope.PrintOut extractaddress:=True, _
omitreturnaddress:=True, _
Size:="size 10", _
AddressFromLeft:=InchesToPoints(3), _
AddressFromTop:=InchesToPoints(1.5)

End Sub
Russ - 26 Oct 2007 19:12 GMT
You created an envelope object in memory and adjusted it's properties. When
your macros stop running the object may no longer be in memory, although you
didn't use 'set myenvelope = Nothing' to free memory, myenvelope with those
properties may no longer exist when you leave VBA run mode.

Have you tried recording a macro while **manually** changing Word's envelope
properties to see what kind of code it produces?

> I accidently posted this under forms.  sorry.
>
[quoted text clipped - 33 lines]
>
> End Sub

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

C Hayes - 30 Oct 2007 15:31 GMT
First, I think your idea of testing the manual build macro is great.  I did
it to no success.  Altering the font size in the dialog box is not captured
in the macro writer.  I filled in an address on a blank document, created a
new macro, recorded the manual steps, changed the font in the dialog box by
right clicking the text and selecting font.  When I went in to review the
created macro here's what I got:

Sub testenvelope()
'
' testenvelope Macro
' Macro recorded 10/30/2007 by jbradley
'
   ActiveDocument.Envelope.PrintOut ExtractAddress:=False,
OmitReturnAddress _
       :=True, PrintBarCode:=False, PrintFIMA:=False,
Height:=InchesToPoints( _
       4.13), Width:=InchesToPoints(9.5), Address:="Johnny M Jones",
AutoText:= _
       "ToolsCreateLabels1", ReturnAddress:="National Kidney Foundation", _
       ReturnAutoText:="ToolsCreateLabels2",
AddressFromLeft:=wdAutoPosition, _
       AddressFromTop:=wdAutoPosition,
ReturnAddressFromLeft:=wdAutoPosition, _
       ReturnAddressFromTop:=wdAutoPosition, DefaultOrientation:= _
       wdCenterLandscape, DefaultFaceUp:=True, PrintEPostage:=False
End Sub

Secondly, I am not following your logic in the envelope object being lost in
memory when I am both altering the attributes of the declaired object then
running a method (namely, 'printout') on said declaired object.  My
housekeeping is a little sloppy, yes I did not release the object from memory.

> You created an envelope object in memory and adjusted it's properties. When
> your macros stop running the object may no longer be in memory, although you
[quoted text clipped - 41 lines]
> >
> > End Sub
Russ - 31 Oct 2007 07:09 GMT
It looks like you should change the "Envelope Return" and "Envelope Address"
styles in the Activedocument, if you want the settings that you change in
the current document to be retained.
ActiveDocument.Styles(wdStyleEnvelopeReturn).Font.Size = 16
ActiveDocument.Styles(wdStyleEnvelopeAddress).Font.Size = 16

The next new blank document will revert back to the default Normal.dot style
values. Since you shouldn't change other users Normal.dot, I would try to
change the style settings in another template other than Normal.dot and then
attach that altered template to documents when I wanted the envelope styles
changed.

Also look at VBA help for the UpdateStylesOnOpen property.

> First, I think your idea of testing the manual build macro is great.  I did
> it to no success.  Altering the font size in the dialog box is not captured
[quoted text clipped - 73 lines]
>>>
>>> End Sub

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

C Hayes - 31 Oct 2007 17:36 GMT
Russ,

I reallly like this answer.  I haven't used it yet but it sounds like the
best way.

Thanks!

Chris

> It looks like you should change the "Envelope Return" and "Envelope Address"
> styles in the Activedocument, if you want the settings that you change in
[quoted text clipped - 87 lines]
> >>>
> >>> End Sub

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.