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

Hello,
This question is mainly for Jay Freedman, but anyone may answer. That sounds
a bit snobby. Sorry! Anyway, Jay you helped me create a macro to unlock,
print an enveope and re-lock a document. That worked well because the address
was in one block and could be highlighted as a block. I have created a new
document and I want to run the same macro. However, the address is in two
blocks and cannot be highlighted as a single block without first unlocking
the document. This totally defeats the purpose of the document. It is an
automated document that uses the REF code to autopopulate the name in two
different pages of the document. To accomplish that I had to use one textbox
for the Name and one textbox for the Address. How do I accomplish this?
Thank you in advance!!
mojr
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Cindy M -WordMVP-
 
Posts: n/a
Default Can I print an envelope without unlocking my document? Slight retu

Hi ?B?TW9KUg==?=,

This question is mainly for Jay Freedman, but anyone may answer. That sounds
a bit snobby. Sorry! Anyway, Jay you helped me create a macro to unlock,
print an enveope and re-lock a document. That worked well because the address
was in one block and could be highlighted as a block. I have created a new
document and I want to run the same macro. However, the address is in two
blocks and cannot be highlighted as a single block without first unlocking
the document. This totally defeats the purpose of the document. It is an
automated document that uses the REF code to autopopulate the name in two
different pages of the document. To accomplish that I had to use one textbox
for the Name and one textbox for the Address. How do I accomplish this?

It might help if you copy the code Jay gave you into a message in this thread.
That way, we'd all (including Jay) have a starting point...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)

  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman
 
Posts: n/a
Default Can I print an envelope without unlocking my document? Slight retu

MoJR wrote:
Hello,
This question is mainly for Jay Freedman, but anyone may answer. That
sounds a bit snobby. Sorry! Anyway, Jay you helped me create a macro
to unlock, print an enveope and re-lock a document. That worked well
because the address was in one block and could be highlighted as a
block. I have created a new document and I want to run the same
macro. However, the address is in two blocks and cannot be
highlighted as a single block without first unlocking the document.
This totally defeats the purpose of the document. It is an automated
document that uses the REF code to autopopulate the name in two
different pages of the document. To accomplish that I had to use one
textbox for the Name and one textbox for the Address. How do I
accomplish this? Thank you in advance!! mojr


Look in the Properties dialogs of the name and address form fields to find
out what their names are (the entry in the Bookmark box, which is the same
thing you use in the Ref fields to repeat the information). If they aren't
"Name" and "Address" then you'll have to change the names used in the
following updated macro:

Sub MakeEnvelope()
Dim addr As String
addr = _
ActiveDocument.FormFields("Name").Result & vbCr & _
ActiveDocument.FormFields("Address").Result

If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect
End If


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


ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
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.


  #4   Report Post  
Posted to microsoft.public.word.docmanagement
MoJR
 
Posts: n/a
Default Can I print an envelope without unlocking my document? Slight

Jay,
The new macro works great. I managed to modify it to include printing my
documents that go with the envelope. However, when I assign it to a
keystroke, it opens the print dialogue. If I then hit 'print' the delivery
address disappears and the envelope does not print, but two copies of the
document will print. When I assign it to a toolbar and click it with the
mouse it works fine. It would be nice to use the keyboard.
Thank you in advance for your help.
mojr

"Jay Freedman" wrote:

MoJR wrote:
Hello,
This question is mainly for Jay Freedman, but anyone may answer. That
sounds a bit snobby. Sorry! Anyway, Jay you helped me create a macro
to unlock, print an enveope and re-lock a document. That worked well
because the address was in one block and could be highlighted as a
block. I have created a new document and I want to run the same
macro. However, the address is in two blocks and cannot be
highlighted as a single block without first unlocking the document.
This totally defeats the purpose of the document. It is an automated
document that uses the REF code to autopopulate the name in two
different pages of the document. To accomplish that I had to use one
textbox for the Name and one textbox for the Address. How do I
accomplish this? Thank you in advance!! mojr


Look in the Properties dialogs of the name and address form fields to find
out what their names are (the entry in the Bookmark box, which is the same
thing you use in the Ref fields to repeat the information). If they aren't
"Name" and "Address" then you'll have to change the names used in the
following updated macro:

Sub MakeEnvelope()
Dim addr As String
addr = _
ActiveDocument.FormFields("Name").Result & vbCr & _
ActiveDocument.FormFields("Address").Result

If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect
End If


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


ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
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.



  #5   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman
 
Posts: n/a
Default Can I print an envelope without unlocking my document? Slight

On Thu, 23 Feb 2006 20:10:27 -0800, "MoJR"
wrote:

Jay,
The new macro works great. I managed to modify it to include printing my
documents that go with the envelope. However, when I assign it to a
keystroke, it opens the print dialogue. If I then hit 'print' the delivery
address disappears and the envelope does not print, but two copies of the
document will print. When I assign it to a toolbar and click it with the
mouse it works fine. It would be nice to use the keyboard.
Thank you in advance for your help.
mojr


I don't know of any (ordinary) way to make a macro behave differently
depending on whether it's launched from a button or a keystroke. It
takes some fairly sophisticated VBA to do that...

First, make absolutely sure that you've assigned the keystroke to the
macro (look in Tools Customize Keyboard and click the macro's name
to see what keystroke is assigned to it).

If that's OK, post your version of the code for me to look at. If I
don't see anything likely, I'll ask you to send me a copy of the
template.

--
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.


  #6   Report Post  
Posted to microsoft.public.word.docmanagement
MoJR
 
Posts: n/a
Default Can I print an envelope without unlocking my document? Slight

Jay,
This is the version of the code I developed.
Sub MakeEnvelope2()
Dim addr As String
addr = _
ActiveDocument.FormFields("name").Result
If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect
End If


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


ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
ActiveDocument.PrintOut
ActiveDocument.Close
End Sub

Thank you,
mojr

"Jay Freedman" wrote:

On Thu, 23 Feb 2006 20:10:27 -0800, "MoJR"
wrote:

Jay,
The new macro works great. I managed to modify it to include printing my
documents that go with the envelope. However, when I assign it to a
keystroke, it opens the print dialogue. If I then hit 'print' the delivery
address disappears and the envelope does not print, but two copies of the
document will print. When I assign it to a toolbar and click it with the
mouse it works fine. It would be nice to use the keyboard.
Thank you in advance for your help.
mojr


I don't know of any (ordinary) way to make a macro behave differently
depending on whether it's launched from a button or a keystroke. It
takes some fairly sophisticated VBA to do that...

First, make absolutely sure that you've assigned the keystroke to the
macro (look in Tools Customize Keyboard and click the macro's name
to see what keystroke is assigned to it).

If that's OK, post your version of the code for me to look at. If I
don't see anything likely, I'll ask you to send me a copy of the
template.

--
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.

  #7   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman
 
Posts: n/a
Default Can I print an envelope without unlocking my document? Slight

I don't see anything there that could cause the symptoms you described. (The
ActiveDocument.PrintOut statement should include the Background:=False
parameter to make the macro wait until spooling has finished before trying
to close the document, but that wouldn't change the behavior so
drastically.)

If you want me to look at the template and try to figure out what's wrong,
zip it and email it to me.

--
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.

MoJR wrote:
Jay,
This is the version of the code I developed.
Sub MakeEnvelope2()
Dim addr As String
addr = _
ActiveDocument.FormFields("name").Result
If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect
End If


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


ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
ActiveDocument.PrintOut
ActiveDocument.Close
End Sub

Thank you,
mojr

"Jay Freedman" wrote:

On Thu, 23 Feb 2006 20:10:27 -0800, "MoJR"
wrote:

Jay,
The new macro works great. I managed to modify it to include
printing my documents that go with the envelope. However, when I
assign it to a keystroke, it opens the print dialogue. If I then
hit 'print' the delivery address disappears and the envelope does
not print, but two copies of the document will print. When I assign
it to a toolbar and click it with the mouse it works fine. It would
be nice to use the keyboard. Thank you in advance for your help.
mojr


I don't know of any (ordinary) way to make a macro behave differently
depending on whether it's launched from a button or a keystroke. It
takes some fairly sophisticated VBA to do that...

First, make absolutely sure that you've assigned the keystroke to the
macro (look in Tools Customize Keyboard and click the macro's
name to see what keystroke is assigned to it).

If that's OK, post your version of the code for me to look at. If I
don't see anything likely, I'll ask you to send me a copy of the
template.

--
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.



  #8   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 guess I didn't put the Backgounf:=False statement in the right place.
Do I need to paste this code into an existing template for it to work as
expected? Currently, it is on a tool bar and not in any existing template.
mojr

"Jay Freedman" wrote:

I don't see anything there that could cause the symptoms you described. (The
ActiveDocument.PrintOut statement should include the Background:=False
parameter to make the macro wait until spooling has finished before trying
to close the document, but that wouldn't change the behavior so
drastically.)

If you want me to look at the template and try to figure out what's wrong,
zip it and email it to me.

--
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.

MoJR wrote:
Jay,
This is the version of the code I developed.
Sub MakeEnvelope2()
Dim addr As String
addr = _
ActiveDocument.FormFields("name").Result
If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect
End If


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


ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
ActiveDocument.PrintOut
ActiveDocument.Close
End Sub

Thank you,
mojr

"Jay Freedman" wrote:

On Thu, 23 Feb 2006 20:10:27 -0800, "MoJR"
wrote:

Jay,
The new macro works great. I managed to modify it to include
printing my documents that go with the envelope. However, when I
assign it to a keystroke, it opens the print dialogue. If I then
hit 'print' the delivery address disappears and the envelope does
not print, but two copies of the document will print. When I assign
it to a toolbar and click it with the mouse it works fine. It would
be nice to use the keyboard. Thank you in advance for your help.
mojr

I don't know of any (ordinary) way to make a macro behave differently
depending on whether it's launched from a button or a keystroke. It
takes some fairly sophisticated VBA to do that...

First, make absolutely sure that you've assigned the keystroke to the
macro (look in Tools Customize Keyboard and click the macro's
name to see what keystroke is assigned to it).

If that's OK, post your version of the code for me to look at. If I
don't see anything likely, I'll ask you to send me a copy of the
template.

--
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.




  #9   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman
 
Posts: n/a
Default Can I print an envelope without unlocking my document? Slight

Whoa, back up the truck... The macro and the toolbar must be stored in some
file, whether a document (.doc) or a template (.dot) file. What is that
file?

MoJR wrote:
Jay,
I guess I didn't put the Backgounf:=False statement in the right
place. Do I need to paste this code into an existing template for it
to work as expected? Currently, it is on a tool bar and not in any
existing template. mojr

"Jay Freedman" wrote:

I don't see anything there that could cause the symptoms you
described. (The ActiveDocument.PrintOut statement should include the
Background:=False parameter to make the macro wait until spooling
has finished before trying to close the document, but that wouldn't
change the behavior so drastically.)

If you want me to look at the template and try to figure out what's
wrong, zip it and email it to me.

--
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.

MoJR wrote:
Jay,
This is the version of the code I developed.
Sub MakeEnvelope2()
Dim addr As String
addr = _
ActiveDocument.FormFields("name").Result
If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect
End If


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


ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
ActiveDocument.PrintOut
ActiveDocument.Close
End Sub

Thank you,
mojr

"Jay Freedman" wrote:

On Thu, 23 Feb 2006 20:10:27 -0800, "MoJR"
wrote:

Jay,
The new macro works great. I managed to modify it to include
printing my documents that go with the envelope. However, when I
assign it to a keystroke, it opens the print dialogue. If I then
hit 'print' the delivery address disappears and the envelope does
not print, but two copies of the document will print. When I
assign it to a toolbar and click it with the mouse it works fine.
It would be nice to use the keyboard. Thank you in advance for
your help. mojr

I don't know of any (ordinary) way to make a macro behave
differently depending on whether it's launched from a button or a
keystroke. It takes some fairly sophisticated VBA to do that...

First, make absolutely sure that you've assigned the keystroke to
the macro (look in Tools Customize Keyboard and click the
macro's name to see what keystroke is assigned to it).

If that's OK, post your version of the code for me to look at. If I
don't see anything likely, I'll ask you to send me a copy of the
template.

--
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.



  #10   Report Post  
Posted to microsoft.public.word.docmanagement
MoJR
 
Posts: n/a
Default Can I print an envelope without unlocking my document? Slight

Jay,
As far as I know, the macro and toolbar are stored in the normal.dot template.
mojr

"Jay Freedman" wrote:

Whoa, back up the truck... The macro and the toolbar must be stored in some
file, whether a document (.doc) or a template (.dot) file. What is that
file?

MoJR wrote:
Jay,
I guess I didn't put the Backgounf:=False statement in the right
place. Do I need to paste this code into an existing template for it
to work as expected? Currently, it is on a tool bar and not in any
existing template. mojr

"Jay Freedman" wrote:

I don't see anything there that could cause the symptoms you
described. (The ActiveDocument.PrintOut statement should include the
Background:=False parameter to make the macro wait until spooling
has finished before trying to close the document, but that wouldn't
change the behavior so drastically.)

If you want me to look at the template and try to figure out what's
wrong, zip it and email it to me.

--
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.

MoJR wrote:
Jay,
This is the version of the code I developed.
Sub MakeEnvelope2()
Dim addr As String
addr = _
ActiveDocument.FormFields("name").Result
If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect
End If


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


ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
ActiveDocument.PrintOut
ActiveDocument.Close
End Sub

Thank you,
mojr

"Jay Freedman" wrote:

On Thu, 23 Feb 2006 20:10:27 -0800, "MoJR"
wrote:

Jay,
The new macro works great. I managed to modify it to include
printing my documents that go with the envelope. However, when I
assign it to a keystroke, it opens the print dialogue. If I then
hit 'print' the delivery address disappears and the envelope does
not print, but two copies of the document will print. When I
assign it to a toolbar and click it with the mouse it works fine.
It would be nice to use the keyboard. Thank you in advance for
your help. mojr

I don't know of any (ordinary) way to make a macro behave
differently depending on whether it's launched from a button or a
keystroke. It takes some fairly sophisticated VBA to do that...

First, make absolutely sure that you've assigned the keystroke to
the macro (look in Tools Customize Keyboard and click the
macro's name to see what keystroke is assigned to it).

If that's OK, post your version of the code for me to look at. If I
don't see anything likely, I'll ask you to send me a copy of the
template.

--
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.






  #11   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman
 
Posts: n/a
Default Can I print an envelope without unlocking my document? Slight

I think we're talking at cross purposes here...

When I mentioned the Background:=False parameter, what I meant was: In
the macro that you already have, which you posted in your message,
there's a line that says

ActiveDocument.PrintOut

You should edit that macro to change that line to

ActiveDocument.PrintOut Background:=False

But I don't expect that change to solve the problem about different
behavior from the toolbar button vs. the shortcut key. I have no
explanation for that problem. As I said before, if that problem
continues and it really bothers you, you can send me a copy of the
template that contains the macro and I'll look at it.

--
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 Fri, 24 Feb 2006 16:55:27 -0800, "MoJR"
wrote:

Jay,
As far as I know, the macro and toolbar are stored in the normal.dot template.
mojr

"Jay Freedman" wrote:

Whoa, back up the truck... The macro and the toolbar must be stored in some
file, whether a document (.doc) or a template (.dot) file. What is that
file?

MoJR wrote:
Jay,
I guess I didn't put the Backgounf:=False statement in the right
place. Do I need to paste this code into an existing template for it
to work as expected? Currently, it is on a tool bar and not in any
existing template. mojr

"Jay Freedman" wrote:

I don't see anything there that could cause the symptoms you
described. (The ActiveDocument.PrintOut statement should include the
Background:=False parameter to make the macro wait until spooling
has finished before trying to close the document, but that wouldn't
change the behavior so drastically.)

If you want me to look at the template and try to figure out what's
wrong, zip it and email it to me.

--
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.

MoJR wrote:
Jay,
This is the version of the code I developed.
Sub MakeEnvelope2()
Dim addr As String
addr = _
ActiveDocument.FormFields("name").Result
If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect
End If


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


ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
ActiveDocument.PrintOut
ActiveDocument.Close
End Sub

Thank you,
mojr

"Jay Freedman" wrote:

On Thu, 23 Feb 2006 20:10:27 -0800, "MoJR"
wrote:

Jay,
The new macro works great. I managed to modify it to include
printing my documents that go with the envelope. However, when I
assign it to a keystroke, it opens the print dialogue. If I then
hit 'print' the delivery address disappears and the envelope does
not print, but two copies of the document will print. When I
assign it to a toolbar and click it with the mouse it works fine.
It would be nice to use the keyboard. Thank you in advance for
your help. mojr

I don't know of any (ordinary) way to make a macro behave
differently depending on whether it's launched from a button or a
keystroke. It takes some fairly sophisticated VBA to do that...

First, make absolutely sure that you've assigned the keystroke to
the macro (look in Tools Customize Keyboard and click the
macro's name to see what keystroke is assigned to it).

If that's OK, post your version of the code for me to look at. If I
don't see anything likely, I'll ask you to send me a copy of the
template.

--
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.




  #12   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 assigned the macro to a hot key. When I press the hot key, the print
dialog comes up. Then, I either click the print button or press Alt+P and
everything works. Is this the way it should work? If it is, can we somehow
eliminate the step that I have to press the print button?
I also inserted the Background:=False parameter and it's working well.
Thank you.
mojr

"Jay Freedman" wrote:

I think we're talking at cross purposes here...

When I mentioned the Background:=False parameter, what I meant was: In
the macro that you already have, which you posted in your message,
there's a line that says

ActiveDocument.PrintOut

You should edit that macro to change that line to

ActiveDocument.PrintOut Background:=False

But I don't expect that change to solve the problem about different
behavior from the toolbar button vs. the shortcut key. I have no
explanation for that problem. As I said before, if that problem
continues and it really bothers you, you can send me a copy of the
template that contains the macro and I'll look at it.

--
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 Fri, 24 Feb 2006 16:55:27 -0800, "MoJR"
wrote:

Jay,
As far as I know, the macro and toolbar are stored in the normal.dot template.
mojr

"Jay Freedman" wrote:

Whoa, back up the truck... The macro and the toolbar must be stored in some
file, whether a document (.doc) or a template (.dot) file. What is that
file?

MoJR wrote:
Jay,
I guess I didn't put the Backgounf:=False statement in the right
place. Do I need to paste this code into an existing template for it
to work as expected? Currently, it is on a tool bar and not in any
existing template. mojr

"Jay Freedman" wrote:

I don't see anything there that could cause the symptoms you
described. (The ActiveDocument.PrintOut statement should include the
Background:=False parameter to make the macro wait until spooling
has finished before trying to close the document, but that wouldn't
change the behavior so drastically.)

If you want me to look at the template and try to figure out what's
wrong, zip it and email it to me.

--
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.

MoJR wrote:
Jay,
This is the version of the code I developed.
Sub MakeEnvelope2()
Dim addr As String
addr = _
ActiveDocument.FormFields("name").Result
If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect
End If


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


ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
ActiveDocument.PrintOut
ActiveDocument.Close
End Sub

Thank you,
mojr

"Jay Freedman" wrote:

On Thu, 23 Feb 2006 20:10:27 -0800, "MoJR"
wrote:

Jay,
The new macro works great. I managed to modify it to include
printing my documents that go with the envelope. However, when I
assign it to a keystroke, it opens the print dialogue. If I then
hit 'print' the delivery address disappears and the envelope does
not print, but two copies of the document will print. When I
assign it to a toolbar and click it with the mouse it works fine.
It would be nice to use the keyboard. Thank you in advance for
your help. mojr

I don't know of any (ordinary) way to make a macro behave
differently depending on whether it's launched from a button or a
keystroke. It takes some fairly sophisticated VBA to do that...

First, make absolutely sure that you've assigned the keystroke to
the macro (look in Tools Customize Keyboard and click the
macro's name to see what keystroke is assigned to it).

If that's OK, post your version of the code for me to look at. If I
don't see anything likely, I'll ask you to send me a copy of the
template.

--
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.




  #13   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman
 
Posts: n/a
Default Can I print an envelope without unlocking my document? Slight

Aha! The light just came on... When you wrote that the "print dialog
comes up", I thought you meant you saw the dialog for the File Print
command. You really meant the Envelope dialog comes up.

Yes, that can be eliminated, but at a price. If you change the line

.Show

to

.Execute

then the envelope will added to the beginning of the document (as if
you had clicked the Add to Document button in the Envelope dialog)
without actually displaying the dialog. The ActiveDocument.Print
command in the macro will then print the whole document, which now
includes the envelope. (I hope your printer can automatically select
the envelope tray for the first "page" and the letter tray for the
remainder.)

The price is that the addition of the envelope will change the
document, so you'll be asked whether to save when the
ActiveDocument.Close statement runs. If you don't want that to happen,
then change the line from

ActiveDocument.Close

to

ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges

--
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 Sat, 25 Feb 2006 17:10:27 -0800, "MoJR"
wrote:

Jay,
I assigned the macro to a hot key. When I press the hot key, the print
dialog comes up. Then, I either click the print button or press Alt+P and
everything works. Is this the way it should work? If it is, can we somehow
eliminate the step that I have to press the print button?
I also inserted the Background:=False parameter and it's working well.
Thank you.
mojr

"Jay Freedman" wrote:

I think we're talking at cross purposes here...

When I mentioned the Background:=False parameter, what I meant was: In
the macro that you already have, which you posted in your message,
there's a line that says

ActiveDocument.PrintOut

You should edit that macro to change that line to

ActiveDocument.PrintOut Background:=False

But I don't expect that change to solve the problem about different
behavior from the toolbar button vs. the shortcut key. I have no
explanation for that problem. As I said before, if that problem
continues and it really bothers you, you can send me a copy of the
template that contains the macro and I'll look at it.

--
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 Fri, 24 Feb 2006 16:55:27 -0800, "MoJR"
wrote:

Jay,
As far as I know, the macro and toolbar are stored in the normal.dot template.
mojr

"Jay Freedman" wrote:

Whoa, back up the truck... The macro and the toolbar must be stored in some
file, whether a document (.doc) or a template (.dot) file. What is that
file?

MoJR wrote:
Jay,
I guess I didn't put the Backgounf:=False statement in the right
place. Do I need to paste this code into an existing template for it
to work as expected? Currently, it is on a tool bar and not in any
existing template. mojr

"Jay Freedman" wrote:

I don't see anything there that could cause the symptoms you
described. (The ActiveDocument.PrintOut statement should include the
Background:=False parameter to make the macro wait until spooling
has finished before trying to close the document, but that wouldn't
change the behavior so drastically.)

If you want me to look at the template and try to figure out what's
wrong, zip it and email it to me.

--
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.

MoJR wrote:
Jay,
This is the version of the code I developed.
Sub MakeEnvelope2()
Dim addr As String
addr = _
ActiveDocument.FormFields("name").Result
If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect
End If


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


ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
ActiveDocument.PrintOut
ActiveDocument.Close
End Sub

Thank you,
mojr

"Jay Freedman" wrote:

On Thu, 23 Feb 2006 20:10:27 -0800, "MoJR"
wrote:

Jay,
The new macro works great. I managed to modify it to include
printing my documents that go with the envelope. However, when I
assign it to a keystroke, it opens the print dialogue. If I then
hit 'print' the delivery address disappears and the envelope does
not print, but two copies of the document will print. When I
assign it to a toolbar and click it with the mouse it works fine.
It would be nice to use the keyboard. Thank you in advance for
your help. mojr

I don't know of any (ordinary) way to make a macro behave
differently depending on whether it's launched from a button or a
keystroke. It takes some fairly sophisticated VBA to do that...

First, make absolutely sure that you've assigned the keystroke to
the macro (look in Tools Customize Keyboard and click the
macro's name to see what keystroke is assigned to it).

If that's OK, post your version of the code for me to look at. If I
don't see anything likely, I'll ask you to send me a copy of the
template.

--
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.




  #14   Report Post  
Posted to microsoft.public.word.docmanagement
MoJR
 
Posts: n/a
Default Can I print an envelope without unlocking my document? Slight

Jay,
Thank you for your help. I will finalize this stuff tomorrow.
Now. I have a document that has 5 pages in it. Three of them are forms. I
need 1 copy of page 1. I need 2 copies of page 2 and I need 3 copies each of
pages 3 and 4 and 1 copy of page 5. I also would like to add 2 envelopes to
this document to be printed when I print the other pages. 1 envelope had a
return and a delivery address that are different. The second evnope uses the
return address for the delivery address as well.
What would be the best way to write "something" that I could use for this?
Is it possible to write it VBA should I try a different program or should I
leave you alone and go screaming into the night!?!?
I asked this question on one of the forums earlier in the week. I can't
remember which one and I haven't received a response on it.
Thank you again!!
mojr
mojr
"Jay Freedman" wrote:

Aha! The light just came on... When you wrote that the "print dialog
comes up", I thought you meant you saw the dialog for the File Print
command. You really meant the Envelope dialog comes up.

Yes, that can be eliminated, but at a price. If you change the line

.Show

to

.Execute

then the envelope will added to the beginning of the document (as if
you had clicked the Add to Document button in the Envelope dialog)
without actually displaying the dialog. The ActiveDocument.Print
command in the macro will then print the whole document, which now
includes the envelope. (I hope your printer can automatically select
the envelope tray for the first "page" and the letter tray for the
remainder.)

The price is that the addition of the envelope will change the
document, so you'll be asked whether to save when the
ActiveDocument.Close statement runs. If you don't want that to happen,
then change the line from

ActiveDocument.Close

to

ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges

--
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 Sat, 25 Feb 2006 17:10:27 -0800, "MoJR"
wrote:

Jay,
I assigned the macro to a hot key. When I press the hot key, the print
dialog comes up. Then, I either click the print button or press Alt+P and
everything works. Is this the way it should work? If it is, can we somehow
eliminate the step that I have to press the print button?
I also inserted the Background:=False parameter and it's working well.
Thank you.
mojr

"Jay Freedman" wrote:

I think we're talking at cross purposes here...

When I mentioned the Background:=False parameter, what I meant was: In
the macro that you already have, which you posted in your message,
there's a line that says

ActiveDocument.PrintOut

You should edit that macro to change that line to

ActiveDocument.PrintOut Background:=False

But I don't expect that change to solve the problem about different
behavior from the toolbar button vs. the shortcut key. I have no
explanation for that problem. As I said before, if that problem
continues and it really bothers you, you can send me a copy of the
template that contains the macro and I'll look at it.

--
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 Fri, 24 Feb 2006 16:55:27 -0800, "MoJR"
wrote:

Jay,
As far as I know, the macro and toolbar are stored in the normal.dot template.
mojr

"Jay Freedman" wrote:

Whoa, back up the truck... The macro and the toolbar must be stored in some
file, whether a document (.doc) or a template (.dot) file. What is that
file?

MoJR wrote:
Jay,
I guess I didn't put the Backgounf:=False statement in the right
place. Do I need to paste this code into an existing template for it
to work as expected? Currently, it is on a tool bar and not in any
existing template. mojr

"Jay Freedman" wrote:

I don't see anything there that could cause the symptoms you
described. (The ActiveDocument.PrintOut statement should include the
Background:=False parameter to make the macro wait until spooling
has finished before trying to close the document, but that wouldn't
change the behavior so drastically.)

If you want me to look at the template and try to figure out what's
wrong, zip it and email it to me.

--
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.

MoJR wrote:
Jay,
This is the version of the code I developed.
Sub MakeEnvelope2()
Dim addr As String
addr = _
ActiveDocument.FormFields("name").Result
If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect
End If


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


ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
ActiveDocument.PrintOut
ActiveDocument.Close
End Sub

Thank you,
mojr

"Jay Freedman" wrote:

On Thu, 23 Feb 2006 20:10:27 -0800, "MoJR"
wrote:

Jay,
The new macro works great. I managed to modify it to include
printing my documents that go with the envelope. However, when I
assign it to a keystroke, it opens the print dialogue. If I then
hit 'print' the delivery address disappears and the envelope does
not print, but two copies of the document will print. When I
assign it to a toolbar and click it with the mouse it works fine.
It would be nice to use the keyboard. Thank you in advance for
your help. mojr

I don't know of any (ordinary) way to make a macro behave
differently depending on whether it's launched from a button or a
keystroke. It takes some fairly sophisticated VBA to do that...

First, make absolutely sure that you've assigned the keystroke to
the macro (look in Tools Customize Keyboard and click the
macro's name to see what keystroke is assigned to it).

If that's OK, post your version of the code for me to look at. If I
don't see anything likely, I'll ask you to send me a copy of the
template.

--
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.





  #15   Report Post  
Posted to microsoft.public.word.docmanagement
MoJR
 
Posts: n/a
Default Can I print an envelope without unlocking my document? Slight

Jay,
The code you sent in the last message didn't really change anything. When I
inserted ".Show to .Execute", I was asked to save the document as you stated.
When I inserted the "ActiveDocument.Close to ActiveDocument.Close
SaveChanges:=wdDoNotSaveChanges", and ran the code, the document printed as
you stated, BUT the original code does that now without changes.

This is the code I am currently using and made the above changes in;Sub
MakeEnvelope()
Dim addr As String
addr = _
ActiveDocument.FormFields("bs2nm").Result & vbCr & _
ActiveDocument.FormFields("bs2ag").Result

If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect
End If


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


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


ActiveDocument.Close
End Sub

Currently, I use a combo key (not hot key, sorry) to run the macro. The
envelope dialog comes up, then I either click the 'print" command or press
Alt+P to actually print the document and envelope. I wan to eliminate the
step the second step if possible. I also need to run a second envelope with
that document that is a return envelope using the return address for delivery
and return.
Thank you,
mojr


"Jay Freedman" wrote:

Aha! The light just came on... When you wrote that the "print dialog
comes up", I thought you meant you saw the dialog for the File Print
command. You really meant the Envelope dialog comes up.

Yes, that can be eliminated, but at a price. If you change the line

.Show

to

.Execute

then the envelope will added to the beginning of the document (as if
you had clicked the Add to Document button in the Envelope dialog)
without actually displaying the dialog. The ActiveDocument.Print
command in the macro will then print the whole document, which now
includes the envelope. (I hope your printer can automatically select
the envelope tray for the first "page" and the letter tray for the
remainder.)

The price is that the addition of the envelope will change the
document, so you'll be asked whether to save when the
ActiveDocument.Close statement runs. If you don't want that to happen,
then change the line from

ActiveDocument.Close

to

ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges

--
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 Sat, 25 Feb 2006 17:10:27 -0800, "MoJR"
wrote:

Jay,
I assigned the macro to a hot key. When I press the hot key, the print
dialog comes up. Then, I either click the print button or press Alt+P and
everything works. Is this the way it should work? If it is, can we somehow
eliminate the step that I have to press the print button?
I also inserted the Background:=False parameter and it's working well.
Thank you.
mojr

"Jay Freedman" wrote:

I think we're talking at cross purposes here...

When I mentioned the Background:=False parameter, what I meant was: In
the macro that you already have, which you posted in your message,
there's a line that says

ActiveDocument.PrintOut

You should edit that macro to change that line to

ActiveDocument.PrintOut Background:=False

But I don't expect that change to solve the problem about different
behavior from the toolbar button vs. the shortcut key. I have no
explanation for that problem. As I said before, if that problem
continues and it really bothers you, you can send me a copy of the
template that contains the macro and I'll look at it.

--
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 Fri, 24 Feb 2006 16:55:27 -0800, "MoJR"
wrote:

Jay,
As far as I know, the macro and toolbar are stored in the normal.dot template.
mojr

"Jay Freedman" wrote:

Whoa, back up the truck... The macro and the toolbar must be stored in some
file, whether a document (.doc) or a template (.dot) file. What is that
file?

MoJR wrote:
Jay,
I guess I didn't put the Backgounf:=False statement in the right
place. Do I need to paste this code into an existing template for it
to work as expected? Currently, it is on a tool bar and not in any
existing template. mojr

"Jay Freedman" wrote:

I don't see anything there that could cause the symptoms you
described. (The ActiveDocument.PrintOut statement should include the
Background:=False parameter to make the macro wait until spooling
has finished before trying to close the document, but that wouldn't
change the behavior so drastically.)

If you want me to look at the template and try to figure out what's
wrong, zip it and email it to me.

--
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.

MoJR wrote:
Jay,
This is the version of the code I developed.
Sub MakeEnvelope2()
Dim addr As String
addr = _
ActiveDocument.FormFields("name").Result
If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect
End If


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


ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
ActiveDocument.PrintOut
ActiveDocument.Close
End Sub

Thank you,
mojr

"Jay Freedman" wrote:

On Thu, 23 Feb 2006 20:10:27 -0800, "MoJR"
wrote:

Jay,
The new macro works great. I managed to modify it to include
printing my documents that go with the envelope. However, when I
assign it to a keystroke, it opens the print dialogue. If I then
hit 'print' the delivery address disappears and the envelope does
not print, but two copies of the document will print. When I
assign it to a toolbar and click it with the mouse it works fine.
It would be nice to use the keyboard. Thank you in advance for
your help. mojr

I don't know of any (ordinary) way to make a macro behave
differently depending on whether it's launched from a button or a
keystroke. It takes some fairly sophisticated VBA to do that...

First, make absolutely sure that you've assigned the keystroke to
the macro (look in Tools Customize Keyboard and click the
macro's name to see what keystroke is assigned to it).

If that's OK, post your version of the code for me to look at. If I
don't see anything likely, I'll ask you to send me a copy of the
template.

--
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.







  #16   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman
 
Posts: n/a
Default Can I print an envelope without unlocking my document? Slight

Hi MoJR,

I don't make this stuff up -- I try it before I post it, and it works here
("here" being two separate computer/printer combinations, at home and at
work). I have to conclude that either you aren't following the instructions
correctly or you have some very different software installation.

When I modify the code as I described, and press the keyboard shortcut to
run the macro, it prints the envelope and the letter without showing any
dialogs or needing any other keys to be pressed. I believe that's the
behavior you're asking for.

Here's the code as I meant you to use it. If it does something other than
what I've described, please tell me *exactly* what happens in what order.

Sub MakeEnvelope()
Dim addr As String
addr = _
ActiveDocument.FormFields("bs2nm").Result & vbCr & _
ActiveDocument.FormFields("bs2ag").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
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.

MoJR wrote:
Jay,
The code you sent in the last message didn't really change anything.
When I inserted ".Show to .Execute", I was asked to save the document
as you stated. When I inserted the "ActiveDocument.Close to
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges", and ran the
code, the document printed as you stated, BUT the original code does
that now without changes.

This is the code I am currently using and made the above changes
in;Sub MakeEnvelope()
Dim addr As String
addr = _
ActiveDocument.FormFields("bs2nm").Result & vbCr & _
ActiveDocument.FormFields("bs2ag").Result

If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect
End If


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


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


ActiveDocument.Close
End Sub

Currently, I use a combo key (not hot key, sorry) to run the macro.
The envelope dialog comes up, then I either click the 'print" command
or press Alt+P to actually print the document and envelope. I wan to
eliminate the step the second step if possible. I also need to run a
second envelope with that document that is a return envelope using
the return address for delivery and return.
Thank you,
mojr


"Jay Freedman" wrote:

Aha! The light just came on... When you wrote that the "print dialog
comes up", I thought you meant you saw the dialog for the File
Print command. You really meant the Envelope dialog comes up.

Yes, that can be eliminated, but at a price. If you change the line

.Show

to

.Execute

then the envelope will added to the beginning of the document (as if
you had clicked the Add to Document button in the Envelope dialog)
without actually displaying the dialog. The ActiveDocument.Print
command in the macro will then print the whole document, which now
includes the envelope. (I hope your printer can automatically select
the envelope tray for the first "page" and the letter tray for the
remainder.)

The price is that the addition of the envelope will change the
document, so you'll be asked whether to save when the
ActiveDocument.Close statement runs. If you don't want that to
happen, then change the line from

ActiveDocument.Close

to

ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges

--
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.



  #17   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman
 
Posts: n/a
Default Can I print an envelope without unlocking my document? Slight

Getting the extra page copies won't be too hard, although I don't have time
right now to play with it until it works right. The idea is that instead of
using the ActiveDocument.PrintOut method, you use the
Dialogs(wdDialogsFilePrint) dialog object -- similar to the way the macro
now uses the Dialogs(wdDialogToolsEnvelopesAndLabels) object -- and use its
Pages parameter to specify a list of the pages and their duplicate copies,
like this:

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

Getting two envelopes might be a little trickier. The problem is that the
macro now acts as if you pressed the Add to Document button in the Envelopes
dialog, and then prints the envelope along with the rest of the document.
But Word allows only one envelope at a time to be attached to a document; if
you try to hand it another envelope, it will replace the one that's already
there. But if the return envelope always has the same address, then that can
be a separate and unchanging document stored in a file on your disk; the
macro can just open it, print it, and close it before or after dealing with
the main document.

--
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.

MoJR wrote:
Jay,
Thank you for your help. I will finalize this stuff tomorrow.
Now. I have a document that has 5 pages in it. Three of them are
forms. I need 1 copy of page 1. I need 2 copies of page 2 and I need
3 copies each of pages 3 and 4 and 1 copy of page 5. I also would
like to add 2 envelopes to this document to be printed when I print
the other pages. 1 envelope had a return and a delivery address that
are different. The second evnope uses the return address for the
delivery address as well. What would be the best way to write
"something" that I could use for this? Is it possible to write it VBA
should I try a different program or should I leave you alone and go
screaming into the night!?!? I asked this question on one of the
forums earlier in the week. I can't remember which one and I haven't
received a response on it. Thank you again!!
mojr



  #18   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 don't know why, but the code I copied into VBA just would not work. I
copied the new code you sent and it worked beautiflly. Obviously I did
something incorrectly.Thank you!!
mojr

"Jay Freedman" wrote:

Hi MoJR,

I don't make this stuff up -- I try it before I post it, and it works here
("here" being two separate computer/printer combinations, at home and at
work). I have to conclude that either you aren't following the instructions
correctly or you have some very different software installation.

When I modify the code as I described, and press the keyboard shortcut to
run the macro, it prints the envelope and the letter without showing any
dialogs or needing any other keys to be pressed. I believe that's the
behavior you're asking for.

Here's the code as I meant you to use it. If it does something other than
what I've described, please tell me *exactly* what happens in what order.

Sub MakeEnvelope()
Dim addr As String
addr = _
ActiveDocument.FormFields("bs2nm").Result & vbCr & _
ActiveDocument.FormFields("bs2ag").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
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.

MoJR wrote:
Jay,
The code you sent in the last message didn't really change anything.
When I inserted ".Show to .Execute", I was asked to save the document
as you stated. When I inserted the "ActiveDocument.Close to
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges", and ran the
code, the document printed as you stated, BUT the original code does
that now without changes.

This is the code I am currently using and made the above changes
in;Sub MakeEnvelope()
Dim addr As String
addr = _
ActiveDocument.FormFields("bs2nm").Result & vbCr & _
ActiveDocument.FormFields("bs2ag").Result

If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect
End If


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


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


ActiveDocument.Close
End Sub

Currently, I use a combo key (not hot key, sorry) to run the macro.
The envelope dialog comes up, then I either click the 'print" command
or press Alt+P to actually print the document and envelope. I wan to
eliminate the step the second step if possible. I also need to run a
second envelope with that document that is a return envelope using
the return address for delivery and return.
Thank you,
mojr


"Jay Freedman" wrote:

Aha! The light just came on... When you wrote that the "print dialog
comes up", I thought you meant you saw the dialog for the File
Print command. You really meant the Envelope dialog comes up.

Yes, that can be eliminated, but at a price. If you change the line

.Show

to

.Execute

then the envelope will added to the beginning of the document (as if
you had clicked the Add to Document button in the Envelope dialog)
without actually displaying the dialog. The ActiveDocument.Print
command in the macro will then print the whole document, which now
includes the envelope. (I hope your printer can automatically select
the envelope tray for the first "page" and the letter tray for the
remainder.)

The price is that the addition of the envelope will change the
document, so you'll be asked whether to save when the
ActiveDocument.Close statement runs. If you don't want that to
happen, then change the line from

ActiveDocument.Close

to

ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges

--
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.




  #19   Report Post  
Posted to microsoft.public.word.docmanagement
MoJR
 
Posts: n/a
Default Can I print an envelope without unlocking my document? Slight

Jay ,
The return envelope uses the same address each time. How do I make it a file?
Do I use the pages parameters on the same line as the (wdDialogsFilePrint)?
mojr

"Jay Freedman" wrote:

Getting the extra page copies won't be too hard, although I don't have time
right now to play with it until it works right. The idea is that instead of
using the ActiveDocument.PrintOut method, you use the
Dialogs(wdDialogsFilePrint) dialog object -- similar to the way the macro
now uses the Dialogs(wdDialogToolsEnvelopesAndLabels) object -- and use its
Pages parameter to specify a list of the pages and their duplicate copies,
like this:

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

Getting two envelopes might be a little trickier. The problem is that the
macro now acts as if you pressed the Add to Document button in the Envelopes
dialog, and then prints the envelope along with the rest of the document.
But Word allows only one envelope at a time to be attached to a document; if
you try to hand it another envelope, it will replace the one that's already
there. But if the return envelope always has the same address, then that can
be a separate and unchanging document stored in a file on your disk; the
macro can just open it, print it, and close it before or after dealing with
the main document.

--
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.

MoJR wrote:
Jay,
Thank you for your help. I will finalize this stuff tomorrow.
Now. I have a document that has 5 pages in it. Three of them are
forms. I need 1 copy of page 1. I need 2 copies of page 2 and I need
3 copies each of pages 3 and 4 and 1 copy of page 5. I also would
like to add 2 envelopes to this document to be printed when I print
the other pages. 1 envelope had a return and a delivery address that
are different. The second evnope uses the return address for the
delivery address as well. What would be the best way to write
"something" that I could use for this? Is it possible to write it VBA
should I try a different program or should I leave you alone and go
screaming into the night!?!? I asked this question on one of the
forums earlier in the week. I can't remember which one and I haven't
received a response on it. Thank you again!!
mojr




  #20   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman
 
Posts: n/a
Default Can I print an envelope without unlocking my document? Slight

I mean that *separate from the macro* you make an ordinary Word
document, but with the page size set for the kind of envelope you use,
and with the address typed on the document as ordinary text. Save that
document somewhere convenient on your disk. Use the path and filename
of that document in the macro to open, print, and close it.

--
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 Mon, 27 Feb 2006 12:59:29 -0800, "MoJR"
wrote:

Jay ,
The return envelope uses the same address each time. How do I make it a file?
Do I use the pages parameters on the same line as the (wdDialogsFilePrint)?
mojr

"Jay Freedman" wrote:

Getting the extra page copies won't be too hard, although I don't have time
right now to play with it until it works right. The idea is that instead of
using the ActiveDocument.PrintOut method, you use the
Dialogs(wdDialogsFilePrint) dialog object -- similar to the way the macro
now uses the Dialogs(wdDialogToolsEnvelopesAndLabels) object -- and use its
Pages parameter to specify a list of the pages and their duplicate copies,
like this:

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

Getting two envelopes might be a little trickier. The problem is that the
macro now acts as if you pressed the Add to Document button in the Envelopes
dialog, and then prints the envelope along with the rest of the document.
But Word allows only one envelope at a time to be attached to a document; if
you try to hand it another envelope, it will replace the one that's already
there. But if the return envelope always has the same address, then that can
be a separate and unchanging document stored in a file on your disk; the
macro can just open it, print it, and close it before or after dealing with
the main document.

--
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.

MoJR wrote:
Jay,
Thank you for your help. I will finalize this stuff tomorrow.
Now. I have a document that has 5 pages in it. Three of them are
forms. I need 1 copy of page 1. I need 2 copies of page 2 and I need
3 copies each of pages 3 and 4 and 1 copy of page 5. I also would
like to add 2 envelopes to this document to be printed when I print
the other pages. 1 envelope had a return and a delivery address that
are different. The second evnope uses the return address for the
delivery address as well. What would be the best way to write
"something" that I could use for this? Is it possible to write it VBA
should I try a different program or should I leave you alone and go
screaming into the night!?!? I asked this question on one of the
forums earlier in the week. I can't remember which one and I haven't
received a response on it. Thank you again!!
mojr






  #21   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 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

"MoJR" wrote:

Jay,
I don't know why, but the code I copied into VBA just would not work. I
copied the new code you sent and it worked beautiflly. Obviously I did
something incorrectly.Thank you!!
mojr

"Jay Freedman" wrote:

Hi MoJR,

I don't make this stuff up -- I try it before I post it, and it works here
("here" being two separate computer/printer combinations, at home and at
work). I have to conclude that either you aren't following the instructions
correctly or you have some very different software installation.

When I modify the code as I described, and press the keyboard shortcut to
run the macro, it prints the envelope and the letter without showing any
dialogs or needing any other keys to be pressed. I believe that's the
behavior you're asking for.

Here's the code as I meant you to use it. If it does something other than
what I've described, please tell me *exactly* what happens in what order.

Sub MakeEnvelope()
Dim addr As String
addr = _
ActiveDocument.FormFields("bs2nm").Result & vbCr & _
ActiveDocument.FormFields("bs2ag").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
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.

MoJR wrote:
Jay,
The code you sent in the last message didn't really change anything.
When I inserted ".Show to .Execute", I was asked to save the document
as you stated. When I inserted the "ActiveDocument.Close to
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges", and ran the
code, the document printed as you stated, BUT the original code does
that now without changes.

This is the code I am currently using and made the above changes
in;Sub MakeEnvelope()
Dim addr As String
addr = _
ActiveDocument.FormFields("bs2nm").Result & vbCr & _
ActiveDocument.FormFields("bs2ag").Result

If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect
End If


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


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


ActiveDocument.Close
End Sub

Currently, I use a combo key (not hot key, sorry) to run the macro.
The envelope dialog comes up, then I either click the 'print" command
or press Alt+P to actually print the document and envelope. I wan to
eliminate the step the second step if possible. I also need to run a
second envelope with that document that is a return envelope using
the return address for delivery and return.
Thank you,
mojr


"Jay Freedman" wrote:

Aha! The light just came on... When you wrote that the "print dialog
comes up", I thought you meant you saw the dialog for the File
Print command. You really meant the Envelope dialog comes up.

Yes, that can be eliminated, but at a price. If you change the line

.Show

to

.Execute

then the envelope will added to the beginning of the document (as if
you had clicked the Add to Document button in the Envelope dialog)
without actually displaying the dialog. The ActiveDocument.Print
command in the macro will then print the whole document, which now
includes the envelope. (I hope your printer can automatically select
the envelope tray for the first "page" and the letter tray for the
remainder.)

The price is that the addition of the envelope will change the
document, so you'll be asked whether to save when the
ActiveDocument.Close statement runs. If you don't want that to
happen, then change the line from

ActiveDocument.Close

to

ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges

--
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.




  #22   Report Post  
Posted to microsoft.public.word.docmanagement
MoJR
 
Posts: n/a
Default Can I print an envelope without unlocking my document? Slight

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

"Jay Freedman" wrote:

Getting the extra page copies won't be too hard, although I don't have time
right now to play with it until it works right. The idea is that instead of
using the ActiveDocument.PrintOut method, you use the
Dialogs(wdDialogsFilePrint) dialog object -- similar to the way the macro
now uses the Dialogs(wdDialogToolsEnvelopesAndLabels) object -- and use its
Pages parameter to specify a list of the pages and their duplicate copies,
like this:

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

Getting two envelopes might be a little trickier. The problem is that the
macro now acts as if you pressed the Add to Document button in the Envelopes
dialog, and then prints the envelope along with the rest of the document.
But Word allows only one envelope at a time to be attached to a document; if
you try to hand it another envelope, it will replace the one that's already
there. But if the return envelope always has the same address, then that can
be a separate and unchanging document stored in a file on your disk; the
macro can just open it, print it, and close it before or after dealing with
the main document.

--
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.

MoJR wrote:
Jay,
Thank you for your help. I will finalize this stuff tomorrow.
Now. I have a document that has 5 pages in it. Three of them are
forms. I need 1 copy of page 1. I need 2 copies of page 2 and I need
3 copies each of pages 3 and 4 and 1 copy of page 5. I also would
like to add 2 envelopes to this document to be printed when I print
the other pages. 1 envelope had a return and a delivery address that
are different. The second evnope uses the return address for the
delivery address as well. What would be the best way to write
"something" that I could use for this? Is it possible to write it VBA
should I try a different program or should I leave you alone and go
screaming into the night!?!? I asked this question on one of the
forums earlier in the week. I can't remember which one and I haven't
received a response on it. Thank you again!!
mojr




  #23   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman
 
Posts: n/a
Default Can I print an envelope without unlocking my document? Slight

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 FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sun, 5 Mar 2006 14:57:16 -0800, MoJR
wrote:

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

"Jay Freedman" wrote:

Getting the extra page copies won't be too hard, although I don't have time
right now to play with it until it works right. The idea is that instead of
using the ActiveDocument.PrintOut method, you use the
Dialogs(wdDialogsFilePrint) dialog object -- similar to the way the macro
now uses the Dialogs(wdDialogToolsEnvelopesAndLabels) object -- and use its
Pages parameter to specify a list of the pages and their duplicate copies,
like this:

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

Getting two envelopes might be a little trickier. The problem is that the
macro now acts as if you pressed the Add to Document button in the Envelopes
dialog, and then prints the envelope along with the rest of the document.
But Word allows only one envelope at a time to be attached to a document; if
you try to hand it another envelope, it will replace the one that's already
there. But if the return envelope always has the same address, then that can
be a separate and unchanging document stored in a file on your disk; the
macro can just open it, print it, and close it before or after dealing with
the main document.

--
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.

MoJR wrote:
Jay,
Thank you for your help. I will finalize this stuff tomorrow.
Now. I have a document that has 5 pages in it. Three of them are
forms. I need 1 copy of page 1. I need 2 copies of page 2 and I need
3 copies each of pages 3 and 4 and 1 copy of page 5. I also would
like to add 2 envelopes to this document to be printed when I print
the other pages. 1 envelope had a return and a delivery address that
are different. The second evnope uses the return address for the
delivery address as well. What would be the best way to write
"something" that I could use for this? Is it possible to write it VBA
should I try a different program or should I leave you alone and go
screaming into the night!?!? I asked this question on one of the
forums earlier in the week. I can't remember which one and I haven't
received a response on it. Thank you again!!
mojr




  #24   Report Post  
Posted to microsoft.public.word.docmanagement
MoJR
 
Posts: n/a
Default Can I print an envelope without unlocking my document? Slight

Jay,
Thank you very, very much for your assistance!! I will work with this in the
morning.
mojr

"Jay Freedman" wrote:

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 FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sun, 5 Mar 2006 14:57:16 -0800, MoJR
wrote:

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

"Jay Freedman" wrote:

Getting the extra page copies won't be too hard, although I don't have time
right now to play with it until it works right. The idea is that instead of
using the ActiveDocument.PrintOut method, you use the
Dialogs(wdDialogsFilePrint) dialog object -- similar to the way the macro
now uses the Dialogs(wdDialogToolsEnvelopesAndLabels) object -- and use its
Pages parameter to specify a list of the pages and their duplicate copies,
like this:

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

Getting two envelopes might be a little trickier. The problem is that the
macro now acts as if you pressed the Add to Document button in the Envelopes
dialog, and then prints the envelope along with the rest of the document.
But Word allows only one envelope at a time to be attached to a document; if
you try to hand it another envelope, it will replace the one that's already
there. But if the return envelope always has the same address, then that can
be a separate and unchanging document stored in a file on your disk; the
macro can just open it, print it, and close it before or after dealing with
the main document.

--
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.

MoJR wrote:
Jay,
Thank you for your help. I will finalize this stuff tomorrow.
Now. I have a document that has 5 pages in it. Three of them are
forms. I need 1 copy of page 1. I need 2 copies of page 2 and I need
3 copies each of pages 3 and 4 and 1 copy of page 5. I also would
like to add 2 envelopes to this document to be printed when I print
the other pages. 1 envelope had a return and a delivery address that
are different. The second evnope uses the return address for the
delivery address as well. What would be the best way to write
"something" that I could use for this? Is it possible to write it VBA
should I try a different program or should I leave you alone and go
screaming into the night!?!? I asked this question on one of the
forums earlier in the week. I can't remember which one and I haven't
received a response on it. Thank you again!!
mojr




  #25   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman
 
Posts: n/a
Default Can I print an envelope without unlocking my document? Slight

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 FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sun, 5 Mar 2006 20:12:27 -0800, MoJR
wrote:

Jay,
Thank you very, very much for your assistance!! I will work with this in the
morning.
mojr

"Jay Freedman" wrote:

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 FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sun, 5 Mar 2006 14:57:16 -0800, MoJR
wrote:

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

"Jay Freedman" wrote:

Getting the extra page copies won't be too hard, although I don't have time
right now to play with it until it works right. The idea is that instead of
using the ActiveDocument.PrintOut method, you use the
Dialogs(wdDialogsFilePrint) dialog object -- similar to the way the macro
now uses the Dialogs(wdDialogToolsEnvelopesAndLabels) object -- and use its
Pages parameter to specify a list of the pages and their duplicate copies,
like this:

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

Getting two envelopes might be a little trickier. The problem is that the
macro now acts as if you pressed the Add to Document button in the Envelopes
dialog, and then prints the envelope along with the rest of the document.
But Word allows only one envelope at a time to be attached to a document; if
you try to hand it another envelope, it will replace the one that's already
there. But if the return envelope always has the same address, then that can
be a separate and unchanging document stored in a file on your disk; the
macro can just open it, print it, and close it before or after dealing with
the main document.

--
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.

MoJR wrote:
Jay,
Thank you for your help. I will finalize this stuff tomorrow.
Now. I have a document that has 5 pages in it. Three of them are
forms. I need 1 copy of page 1. I need 2 copies of page 2 and I need
3 copies each of pages 3 and 4 and 1 copy of page 5. I also would
like to add 2 envelopes to this document to be printed when I print
the other pages. 1 envelope had a return and a delivery address that
are different. The second evnope uses the return address for the
delivery address as well. What would be the best way to write
"something" that I could use for this? Is it possible to write it VBA
should I try a different program or should I leave you alone and go
screaming into the night!?!? I asked this question on one of the
forums earlier in the week. I can't remember which one and I haven't
received a response on it. Thank you again!!
mojr






  #26   Report Post  
Posted to microsoft.public.word.docmanagement
MoJR
 
Posts: n/a
Default Can I print an envelope without unlocking my document? Slight

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 Freedman" wrote:

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 FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sun, 5 Mar 2006 20:12:27 -0800, MoJR
wrote:

Jay,
Thank you very, very much for your assistance!! I will work with this in the
morning.
mojr

"Jay Freedman" wrote:

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 FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sun, 5 Mar 2006 14:57:16 -0800, MoJR
wrote:

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

"Jay Freedman" wrote:

Getting the extra page copies won't be too hard, although I don't have time
right now to play with it until it works right. The idea is that instead of
using the ActiveDocument.PrintOut method, you use the
Dialogs(wdDialogsFilePrint) dialog object -- similar to the way the macro
now uses the Dialogs(wdDialogToolsEnvelopesAndLabels) object -- and use its
Pages parameter to specify a list of the pages and their duplicate copies,
like this:

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

Getting two envelopes might be a little trickier. The problem is that the
macro now acts as if you pressed the Add to Document button in the Envelopes
dialog, and then prints the envelope along with the rest of the document.
But Word allows only one envelope at a time to be attached to a document; if
you try to hand it another envelope, it will replace the one that's already
there. But if the return envelope always has the same address, then that can
be a separate and unchanging document stored in a file on your disk; the
macro can just open it, print it, and close it before or after dealing with
the main document.

--
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.

MoJR wrote:
Jay,
Thank you for your help. I will finalize this stuff tomorrow.
Now. I have a document that has 5 pages in it. Three of them are
forms. I need 1 copy of page 1. I need 2 copies of page 2 and I need
3 copies each of pages 3 and 4 and 1 copy of page 5. I also would
like to add 2 envelopes to this document to be printed when I print
the other pages. 1 envelope had a return and a delivery address that
are different. The second evnope uses the return address for the
delivery address as well. What would be the best way to write
"something" that I could use for this? Is it possible to write it VBA
should I try a different program or should I leave you alone and go
screaming into the night!?!? I asked this question on one of the
forums earlier in the week. I can't remember which one and I haven't
received a response on it. Thank you again!!
mojr





  #27   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 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

"Jay Freedman" wrote:

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 FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sun, 5 Mar 2006 20:12:27 -0800, MoJR
wrote:

Jay,
Thank you very, very much for your assistance!! I will work with this in the
morning.
mojr

"Jay Freedman" wrote:

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 FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sun, 5 Mar 2006 14:57:16 -0800, MoJR
wrote:

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

"Jay Freedman" wrote:

Getting the extra page copies won't be too hard, although I don't have time
right now to play with it until it works right. The idea is that instead of
using the ActiveDocument.PrintOut method, you use the
Dialogs(wdDialogsFilePrint) dialog object -- similar to the way the macro
now uses the Dialogs(wdDialogToolsEnvelopesAndLabels) object -- and use its
Pages parameter to specify a list of the pages and their duplicate copies,
like this:

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

Getting two envelopes might be a little trickier. The problem is that the
macro now acts as if you pressed the Add to Document button in the Envelopes
dialog, and then prints the envelope along with the rest of the document.
But Word allows only one envelope at a time to be attached to a document; if
you try to hand it another envelope, it will replace the one that's already
there. But if the return envelope always has the same address, then that can
be a separate and unchanging document stored in a file on your disk; the
macro can just open it, print it, and close it before or after dealing with
the main document.

--
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.

MoJR wrote:
Jay,
Thank you for your help. I will finalize this stuff tomorrow.
Now. I have a document that has 5 pages in it. Three of them are
forms. I need 1 copy of page 1. I need 2 copies of page 2 and I need
3 copies each of pages 3 and 4 and 1 copy of page 5. I also would
like to add 2 envelopes to this document to be printed when I print
the other pages. 1 envelope had a return and a delivery address that
are different. The second evnope uses the return address for the
delivery address as well. What would be the best way to write
"something" that I could use for this? Is it possible to write it VBA
should I try a different program or should I leave you alone and go
screaming into the night!?!? I asked this question on one of the
forums earlier in the week. I can't remember which one and I haven't
received a response on it. Thank you again!!
mojr





  #28   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman
 
Posts: n/a
Default Can I print an envelope without unlocking my document? Slight

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

  #29   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


Reply
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 03:09 PM.

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"