Can I print an envelope without unlocking my document? Slight retu

  • Thread starter Thread starter Guest
  • Start date Start date
Jay,
I believe I have the envelope situation under control. Thank you for that.
Printing a different number of copies for each page of the document I
mentioned has confounded me. I tried writing some code for that. I managed to
get the first couple of lines, but after that I was lost.
Thank yiou,
mojr
 
Jay,
Please don't forget about the code mentioned in the is e-mail. I really do
need it to complete the document referenced. I tried doing this on my own and
failed miserably.
Thank You,
mojr
 
Sorry, I got caught up in a high-priority job at work and forgot that
I left you waiting for this.

In the macro you already have, remove the line that contains
"ActiveDocument.PrintOut" and replace it with these lines:

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

Of course, you can change the list of numbers to suit your needs.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
Jay,
Thank you very, very much for your assistance!! I will work with this in the
morning.
mojr
 
It occurred to me, a bit belatedly, that the last version of the macro
adds the envelope to the start of the document as page 0. That means
your list of pages should be

.Pages = "0,1,2,2,3,3,3,4,4,4,5"

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
Jay,
The macro as I wrote it is as follows;

Documents.Add Template:= _
"C:\Documents and Settings\MoJR\Application
Data\Microsoft\Templates\JR\XXXX.dot" _
, NewTemplate:=False, DocumentType:=0
Documents.Add Template:= _
"C:\Documents and Settings\MoJR\Application
Data\Microsoft\Templates\JR\XXXXXX.dot" _
, NewTemplate:=False, DocumentType:=0
With Dialogs(wdDialogFilePrint)
.Background = False
.Range = wdPrintRangeOfPages
.Pages = "0,1,2,2,3,3,3,4,1,5"
.Execute
End With
ActiveDocument.Close
It does not print the required copies of each page and it does not prompt me
for an envelope. I must have left out all the good parts. The pages and their
copies are;
1of page 1, 2 of page 2, 3 of page 3 and 3 of page 4. I obviously did not
enter the pages correctly in the macro. How do I enter these pages and their
copeis?
I have the macro you sent for printing 2 envelopes. It prints 1 envelope
with a delivery and return address and prints 1 envelope that uses the return
address as the delivery address. I don't really want the above macro to print
an envelope.
Thanks again in advance. You have the patience of a saint!!
mojr
 
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
 
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
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
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
 

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

Back
Top