Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #25   Report Post  
Posted to microsoft.public.word.docmanagement
MoJR
 
Posts: n/a
Default Can I print an envelope without unlocking my document? Slight

Jay,
I created a toolbar with other forms on it that open by a macro. I did this
for convenience. They all work very well. I want to put the MoJR Packet on
there as well.
1. Why can't I use a macro to open the MoJR Packet?
2. Is it possible to get the MoJR template on to the toolbar instead?
3. How do I create a module?
4. How do I get that module into the "MoJR Packet.dot" template.
Thank you for your patience!!
mojr

"Jay Freedman" wrote:

First, understand that _all_ code must be between a line that starts
with "Sub" and a line that says "End Sub". If you try to stick some
code before the first Sub line, you'll just get a syntax error.

Second, you've now achieved a mishmash of bits and pieces that
wouldn't work together even if you got them in the right places.

The sequence of events you want, if I understand correctly what's in
the templates "MoJR Packet.dot" and "packet envelope.dot", is this:

1. Create a new document based on "MoJR Packet.dot" -- _not_ through a
macro, but by clicking File New and choosing that template. This new
document is a protected form that includes the fields pnm1 and padd1
through padd3. You manually enter name and address information in
these fields. If you want to keep a copy of the letter, you manually
save the document and give it a file name.

2. Press a key combination or click a toolbar button to run the
MakeEnvelope macro, which is stored in a module in the "MoJR
Packet.dot" template.

3. The macro mimics using the Envelope dialog and clicking the Add to
Document button to insert an envelope as page 0. Then it prints the
entire document, including the envelope and multiple copies of several
pages. The document should then be closed without being saved, so the
stored file doesn't include the envelope.

4. The macro creates a new document based on "packet envelope.dot"
which is a return envelope, prints it, and closes it without saving.

The macro that does steps 3 and 4 should look like this:

Sub MakeEnvelope()
Dim addr As String
addr = _
ActiveDocument.FormFields("pnm1").Result & vbCr & _
ActiveDocument.FormFields("padd1").Result
ActiveDocument.FormFields("padd2").Result
ActiveDocument.FormFields("padd3").Result

If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect
End If

With Dialogs(wdDialogToolsEnvelopesAndLabels)
.DefaultTab = _
wdDialogToolsEnvelopesAndLabelsTabEnvelopes
.EnvReturn = Application.UserAddress
.AddrText = addr
.Execute
End With


ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True

With Dialogs(wdDialogFilePrint)
.Background = False
.Range = wdPrintRangeOfPages
.Pages = "0,1,2,2,3,3,3,4,4,4,5"
.Execute
End With

ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges

Documents.Add Template:= _
"C:\Documents and Settings\MoJR\Application Data" _
& "\Microsoft\Templates\JR\packet envelope.dot", _
NewTemplate:=False, DocumentType:=0

ActiveDocument.PrintOut Background:=False

ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
End Sub


--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Tue, 7 Mar 2006 20:23:27 -0800, MoJR
wrote:

Jay,
I tried your suggestion on getting extra pages to print. It didn't work.
This is the code I wrote;
Documents.Add Template:= _
"C:\Documents and Settings\MoJR\Application
Data\Microsoft\Templates\JR\MoJR Packet.dot" _
, NewTemplate:=False, DocumentType:=0

With Dialogs(wdDialogFilePrint)
.Background = False
.Range = wdPrintRangeOfPages
.Pages = "1,2,2,3,3,3,4,4,4,5"
.Execute
End With
ActiveDocument.PrintOut

Sub MakeEnvelope()
Dim addr As String
addr = _
ActiveDocument.FormFields("pnm1").Result & vbCr & _
ActiveDocument.FormFields("padd1").Result
ActiveDocument.FormFields("padd2").Result
ActiveDocument.FormFields("padd3").Result

If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect
End If

With Dialogs(wdDialogToolsEnvelopesAndLabels)
.DefaultTab = _
wdDialogToolsEnvelopesAndLabelsTabEnvelopes
.EnvReturn = Application.UserAddress
.AddrText = addr
.Execute
End With


ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
ActiveDocument.PrintOut Background:=False
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges

Documents.Add Template:= _
"C:\Documents and Settings\MoJR\Application
Data\Microsoft\Templates\JR\packet envelope.dot" _
, NewTemplate:=False, DocumentType:=0
ActiveDocument.PrintOut
ActiveDocument.Close

End Sub

I would appreciate your help with this. I apparently don't understand as
much about VBA as I thought.
Thanks You,
mojr




 
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I get a No. 6 3/4 envelope to print correctly? HarrietYee Mailmerge 3 May 12th 23 02:52 PM
print preview and actual print is different from original document inenewbl Page Layout 1 February 16th 06 01:49 PM
during print preview legal size document cuts to letter size Jim Microsoft Word Help 0 April 19th 05 11:00 PM
Section of a Word Document Fails to Print and Drops Out of Attachm Manannan Microsoft Word Help 0 March 13th 05 02:31 PM
One document - Two Printers (envelope and laser) John Foy Microsoft Word Help 0 March 9th 05 07:03 PM


All times are GMT +1. The time now is 11:57 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"