Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Setting a print tray
I am trying to use a macro on my mail merge template(Word2003) to set a
specific print tray. I am calling the merge from access2003 and then am printing out the new merged document from a module in access. I am unsuccessful in trying to add a macro I found (www.gmayor.com/fax_from_word.htm) to place on my template so each document will print to a different tray. I don't know if I am doing something wrong or am missing something. I am able to run it from Word and it will switch the printer but not switch the tray. Then when I call the whole thing into Access it will switch printers but not print trays.I have placed the code on the mail merge template itself in the Document New, because to my limited knowledge this code is suppose to carry over to the merged documents.Is that true? I have the code below to view.Thank you ahead for any help. Private Sub Document_New() Dim sCurrentPrinter As String sCurrentPrinter = Application.ActivePrinter ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" With Options .DefaultTray = "Tray 2" End With Application.PrintOut FileName:="" With Options .DefaultTray = "Use printer settings" End With ActivePrinter = sCurrentPrinter End Sub |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Setting a print tray
What does the Message Box (below) report?
If, as I suspect, it says Tray 2 - is there a Tray 2 associated with this printer or is it called something else? Try setting the tray assignment in the document's page setup (with the required printer active). -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Private Sub Document_New() Dim sCurrentPrinter As String sCurrentPrinter = Application.ActivePrinter ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" With Options .DefaultTray = "Tray 2" End With MsgBox Options.DefaultTray 'Application.PrintOut FileName:="" With Options .DefaultTray = "Use printer settings" End With ActivePrinter = sCurrentPrinter End Sub AJ wrote: I am trying to use a macro on my mail merge template(Word2003) to set a specific print tray. I am calling the merge from access2003 and then am printing out the new merged document from a module in access. I am unsuccessful in trying to add a macro I found (www.gmayor.com/fax_from_word.htm) to place on my template so each document will print to a different tray. I don't know if I am doing something wrong or am missing something. I am able to run it from Word and it will switch the printer but not switch the tray. Then when I call the whole thing into Access it will switch printers but not print trays.I have placed the code on the mail merge template itself in the Document New, because to my limited knowledge this code is suppose to carry over to the merged documents.Is that true? I have the code below to view.Thank you ahead for any help. Private Sub Document_New() Dim sCurrentPrinter As String sCurrentPrinter = Application.ActivePrinter ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" With Options .DefaultTray = "Tray 2" End With Application.PrintOut FileName:="" With Options .DefaultTray = "Use printer settings" End With ActivePrinter = sCurrentPrinter End Sub |
#3
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Setting a print tray
Oops! By 'below' I meant in the revised macro
Private Sub Document_New() Dim sCurrentPrinter As String sCurrentPrinter = Application.ActivePrinter ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" With Options .DefaultTray = "Tray 2" End With MsgBox Options.DefaultTray 'Application.PrintOut FileName:="" With Options .DefaultTray = "Use printer settings" End With ActivePrinter = sCurrentPrinter End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Graham Mayor wrote: What does the Message Box (below) report? If, as I suspect, it says Tray 2 - is there a Tray 2 associated with this printer or is it called something else? Try setting the tray assignment in the document's page setup (with the required printer active). AJ wrote: I am trying to use a macro on my mail merge template(Word2003) to set a specific print tray. I am calling the merge from access2003 and then am printing out the new merged document from a module in access. I am unsuccessful in trying to add a macro I found (www.gmayor.com/fax_from_word.htm) to place on my template so each document will print to a different tray. I don't know if I am doing something wrong or am missing something. I am able to run it from Word and it will switch the printer but not switch the tray. Then when I call the whole thing into Access it will switch printers but not print trays.I have placed the code on the mail merge template itself in the Document New, because to my limited knowledge this code is suppose to carry over to the merged documents.Is that true? I have the code below to view.Thank you ahead for any help. Private Sub Document_New() Dim sCurrentPrinter As String sCurrentPrinter = Application.ActivePrinter ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" With Options .DefaultTray = "Tray 2" End With Application.PrintOut FileName:="" With Options .DefaultTray = "Use printer settings" End With ActivePrinter = sCurrentPrinter End Sub |
#4
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Setting a print tray
Mr. Mayor,
First thank you so much for your time and help. I replaced the code with the revised one and the message box came up with "Use Printer Settings". It did not change trays yet again. I went to the page setup of the document with the duplex printer selected and "Tray 2" is an option but yet no luck. I don't know what I am doing wrong. Any other direction? Thank you for any help. Thanks, AJ "Graham Mayor" wrote: Oops! By 'below' I meant in the revised macro Private Sub Document_New() Dim sCurrentPrinter As String sCurrentPrinter = Application.ActivePrinter ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" With Options .DefaultTray = "Tray 2" End With MsgBox Options.DefaultTray 'Application.PrintOut FileName:="" With Options .DefaultTray = "Use printer settings" End With ActivePrinter = sCurrentPrinter End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Graham Mayor wrote: What does the Message Box (below) report? If, as I suspect, it says Tray 2 - is there a Tray 2 associated with this printer or is it called something else? Try setting the tray assignment in the document's page setup (with the required printer active). AJ wrote: I am trying to use a macro on my mail merge template(Word2003) to set a specific print tray. I am calling the merge from access2003 and then am printing out the new merged document from a module in access. I am unsuccessful in trying to add a macro I found (www.gmayor.com/fax_from_word.htm) to place on my template so each document will print to a different tray. I don't know if I am doing something wrong or am missing something. I am able to run it from Word and it will switch the printer but not switch the tray. Then when I call the whole thing into Access it will switch printers but not print trays.I have placed the code on the mail merge template itself in the Document New, because to my limited knowledge this code is suppose to carry over to the merged documents.Is that true? I have the code below to view.Thank you ahead for any help. Private Sub Document_New() Dim sCurrentPrinter As String sCurrentPrinter = Application.ActivePrinter ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" With Options .DefaultTray = "Tray 2" End With Application.PrintOut FileName:="" With Options .DefaultTray = "Use printer settings" End With ActivePrinter = sCurrentPrinter End Sub |
#5
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Setting a print tray
Also, I don't know if this makes any difference, but when I step through the
macro, when it gets to the "With Options . defaulttray" line 1 of 2 things happens, either it goes through it without the normal pause you get when it is running a code. Like when it does the activeprinter line there is a pause while it runs the code and switches printers, but on this line and the other option line further in the code it either jumps right through it without any pause Or at other times when it gets to the option line the program freezes up and I get the "Word has encountered a problem and must shut down". I hope this makes since, basically it seems like it either skips over the "With options" or if it tries to run it I get the Message about encountering a problem. I don't know if it makes a difference that I am using Word2003. "Graham Mayor" wrote: Oops! By 'below' I meant in the revised macro Private Sub Document_New() Dim sCurrentPrinter As String sCurrentPrinter = Application.ActivePrinter ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" With Options .DefaultTray = "Tray 2" End With MsgBox Options.DefaultTray 'Application.PrintOut FileName:="" With Options .DefaultTray = "Use printer settings" End With ActivePrinter = sCurrentPrinter End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Graham Mayor wrote: What does the Message Box (below) report? If, as I suspect, it says Tray 2 - is there a Tray 2 associated with this printer or is it called something else? Try setting the tray assignment in the document's page setup (with the required printer active). AJ wrote: I am trying to use a macro on my mail merge template(Word2003) to set a specific print tray. I am calling the merge from access2003 and then am printing out the new merged document from a module in access. I am unsuccessful in trying to add a macro I found (www.gmayor.com/fax_from_word.htm) to place on my template so each document will print to a different tray. I don't know if I am doing something wrong or am missing something. I am able to run it from Word and it will switch the printer but not switch the tray. Then when I call the whole thing into Access it will switch printers but not print trays.I have placed the code on the mail merge template itself in the Document New, because to my limited knowledge this code is suppose to carry over to the merged documents.Is that true? I have the code below to view.Thank you ahead for any help. Private Sub Document_New() Dim sCurrentPrinter As String sCurrentPrinter = Application.ActivePrinter ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" With Options .DefaultTray = "Tray 2" End With Application.PrintOut FileName:="" With Options .DefaultTray = "Use printer settings" End With ActivePrinter = sCurrentPrinter End Sub |
#6
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Setting a print tray
P.S.
Just a little more information. When i step through the code, either 1 of 2 things happen. First, I will step through and get to the "With Options" line and the program steps right through it without any pause. Usually when the program is performing the code you will get a little pause until it finishes, but I don't. OR, the other thing that is happening now, is when I step through the code and get to the "With Options" line, the program freezes up and I get the "Word has encountered a problem and must shut down" error box. This morning everytime it tries to run the "WithOptions" line of code it pauses then the error mssg comes up. Thanks, "AJ" wrote: Mr. Mayor, First thank you so much for your time and help. I replaced the code with the revised one and the message box came up with "Use Printer Settings". It did not change trays yet again. I went to the page setup of the document with the duplex printer selected and "Tray 2" is an option but yet no luck. I don't know what I am doing wrong. Any other direction? Thank you for any help. Thanks, AJ "Graham Mayor" wrote: Oops! By 'below' I meant in the revised macro Private Sub Document_New() Dim sCurrentPrinter As String sCurrentPrinter = Application.ActivePrinter ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" With Options .DefaultTray = "Tray 2" End With MsgBox Options.DefaultTray 'Application.PrintOut FileName:="" With Options .DefaultTray = "Use printer settings" End With ActivePrinter = sCurrentPrinter End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Graham Mayor wrote: What does the Message Box (below) report? If, as I suspect, it says Tray 2 - is there a Tray 2 associated with this printer or is it called something else? Try setting the tray assignment in the document's page setup (with the required printer active). AJ wrote: I am trying to use a macro on my mail merge template(Word2003) to set a specific print tray. I am calling the merge from access2003 and then am printing out the new merged document from a module in access. I am unsuccessful in trying to add a macro I found (www.gmayor.com/fax_from_word.htm) to place on my template so each document will print to a different tray. I don't know if I am doing something wrong or am missing something. I am able to run it from Word and it will switch the printer but not switch the tray. Then when I call the whole thing into Access it will switch printers but not print trays.I have placed the code on the mail merge template itself in the Document New, because to my limited knowledge this code is suppose to carry over to the merged documents.Is that true? I have the code below to view.Thank you ahead for any help. Private Sub Document_New() Dim sCurrentPrinter As String sCurrentPrinter = Application.ActivePrinter ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" With Options .DefaultTray = "Tray 2" End With Application.PrintOut FileName:="" With Options .DefaultTray = "Use printer settings" End With ActivePrinter = sCurrentPrinter End Sub |
#7
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Setting a print tray
This is all very odd? Testing here I too find that Word 2003 crashes if you
change the default tray in vba with the example used. It certainly didn't do that when I wrote the web page One unsatisfactory workaround is to use the following code Dim sPrinter As String With Dialogs(wdDialogFilePrintSetup) sPrinter = .Printer .Printer = "\\OKKC405\IT_PS.PRINTERS" .DoNotSetAsSysDefault = True .Execute Dialogs(wdDialogFilePrint).Show .Printer = sPrinter .DoNotSetAsSysDefault = False .Execute End With which will at least pause while you change the tray manually. A more in depth look at controlling printers by VBA has been conducted by fellow MVP Jonathan West - see http://pubs.logicalexpressions.com/P...cle.asp?ID=116 -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org AJ wrote: Also, I don't know if this makes any difference, but when I step through the macro, when it gets to the "With Options . defaulttray" line 1 of 2 things happens, either it goes through it without the normal pause you get when it is running a code. Like when it does the activeprinter line there is a pause while it runs the code and switches printers, but on this line and the other option line further in the code it either jumps right through it without any pause Or at other times when it gets to the option line the program freezes up and I get the "Word has encountered a problem and must shut down". I hope this makes since, basically it seems like it either skips over the "With options" or if it tries to run it I get the Message about encountering a problem. I don't know if it makes a difference that I am using Word2003. "Graham Mayor" wrote: Oops! By 'below' I meant in the revised macro Private Sub Document_New() Dim sCurrentPrinter As String sCurrentPrinter = Application.ActivePrinter ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" With Options .DefaultTray = "Tray 2" End With MsgBox Options.DefaultTray 'Application.PrintOut FileName:="" With Options .DefaultTray = "Use printer settings" End With ActivePrinter = sCurrentPrinter End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Graham Mayor wrote: What does the Message Box (below) report? If, as I suspect, it says Tray 2 - is there a Tray 2 associated with this printer or is it called something else? Try setting the tray assignment in the document's page setup (with the required printer active). AJ wrote: I am trying to use a macro on my mail merge template(Word2003) to set a specific print tray. I am calling the merge from access2003 and then am printing out the new merged document from a module in access. I am unsuccessful in trying to add a macro I found (www.gmayor.com/fax_from_word.htm) to place on my template so each document will print to a different tray. I don't know if I am doing something wrong or am missing something. I am able to run it from Word and it will switch the printer but not switch the tray. Then when I call the whole thing into Access it will switch printers but not print trays.I have placed the code on the mail merge template itself in the Document New, because to my limited knowledge this code is suppose to carry over to the merged documents.Is that true? I have the code below to view.Thank you ahead for any help. Private Sub Document_New() Dim sCurrentPrinter As String sCurrentPrinter = Application.ActivePrinter ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" With Options .DefaultTray = "Tray 2" End With Application.PrintOut FileName:="" With Options .DefaultTray = "Use printer settings" End With ActivePrinter = sCurrentPrinter End Sub |
#8
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Setting a print tray
PS - Given the crashes, you should also see
http://www.gmayor.com/what_to_do_when_word_crashes.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Graham Mayor wrote: This is all very odd? Testing here I too find that Word 2003 crashes if you change the default tray in vba with the example used. It certainly didn't do that when I wrote the web page One unsatisfactory workaround is to use the following code Dim sPrinter As String With Dialogs(wdDialogFilePrintSetup) sPrinter = .Printer .Printer = "\\OKKC405\IT_PS.PRINTERS" .DoNotSetAsSysDefault = True .Execute Dialogs(wdDialogFilePrint).Show .Printer = sPrinter .DoNotSetAsSysDefault = False .Execute End With which will at least pause while you change the tray manually. A more in depth look at controlling printers by VBA has been conducted by fellow MVP Jonathan West - see http://pubs.logicalexpressions.com/P...cle.asp?ID=116 AJ wrote: Also, I don't know if this makes any difference, but when I step through the macro, when it gets to the "With Options . defaulttray" line 1 of 2 things happens, either it goes through it without the normal pause you get when it is running a code. Like when it does the activeprinter line there is a pause while it runs the code and switches printers, but on this line and the other option line further in the code it either jumps right through it without any pause Or at other times when it gets to the option line the program freezes up and I get the "Word has encountered a problem and must shut down". I hope this makes since, basically it seems like it either skips over the "With options" or if it tries to run it I get the Message about encountering a problem. I don't know if it makes a difference that I am using Word2003. "Graham Mayor" wrote: Oops! By 'below' I meant in the revised macro Private Sub Document_New() Dim sCurrentPrinter As String sCurrentPrinter = Application.ActivePrinter ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" With Options .DefaultTray = "Tray 2" End With MsgBox Options.DefaultTray 'Application.PrintOut FileName:="" With Options .DefaultTray = "Use printer settings" End With ActivePrinter = sCurrentPrinter End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Graham Mayor wrote: What does the Message Box (below) report? If, as I suspect, it says Tray 2 - is there a Tray 2 associated with this printer or is it called something else? Try setting the tray assignment in the document's page setup (with the required printer active). AJ wrote: I am trying to use a macro on my mail merge template(Word2003) to set a specific print tray. I am calling the merge from access2003 and then am printing out the new merged document from a module in access. I am unsuccessful in trying to add a macro I found (www.gmayor.com/fax_from_word.htm) to place on my template so each document will print to a different tray. I don't know if I am doing something wrong or am missing something. I am able to run it from Word and it will switch the printer but not switch the tray. Then when I call the whole thing into Access it will switch printers but not print trays.I have placed the code on the mail merge template itself in the Document New, because to my limited knowledge this code is suppose to carry over to the merged documents.Is that true? I have the code below to view.Thank you ahead for any help. Private Sub Document_New() Dim sCurrentPrinter As String sCurrentPrinter = Application.ActivePrinter ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" With Options .DefaultTray = "Tray 2" End With Application.PrintOut FileName:="" With Options .DefaultTray = "Use printer settings" End With ActivePrinter = sCurrentPrinter End Sub |
#9
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Setting a print tray
Thanks Mr. Mayor, I have been doing the backup and clearing out the trash
files. Since this has been doing this for a couple of days now, I have become very proficient at backups... At least I can feel better at the fact that it isn't that Word just hates me and is bound and determined to drive me to the Psych Ward... I will look into the other site you suggested and see what to do from here. If you are able to figure anything out please let me know, this is going to bug me for days... Thanks, AJ "Graham Mayor" wrote: PS - Given the crashes, you should also see http://www.gmayor.com/what_to_do_when_word_crashes.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Graham Mayor wrote: This is all very odd? Testing here I too find that Word 2003 crashes if you change the default tray in vba with the example used. It certainly didn't do that when I wrote the web page One unsatisfactory workaround is to use the following code Dim sPrinter As String With Dialogs(wdDialogFilePrintSetup) sPrinter = .Printer .Printer = "\\OKKC405\IT_PS.PRINTERS" .DoNotSetAsSysDefault = True .Execute Dialogs(wdDialogFilePrint).Show .Printer = sPrinter .DoNotSetAsSysDefault = False .Execute End With which will at least pause while you change the tray manually. A more in depth look at controlling printers by VBA has been conducted by fellow MVP Jonathan West - see http://pubs.logicalexpressions.com/P...cle.asp?ID=116 AJ wrote: Also, I don't know if this makes any difference, but when I step through the macro, when it gets to the "With Options . defaulttray" line 1 of 2 things happens, either it goes through it without the normal pause you get when it is running a code. Like when it does the activeprinter line there is a pause while it runs the code and switches printers, but on this line and the other option line further in the code it either jumps right through it without any pause Or at other times when it gets to the option line the program freezes up and I get the "Word has encountered a problem and must shut down". I hope this makes since, basically it seems like it either skips over the "With options" or if it tries to run it I get the Message about encountering a problem. I don't know if it makes a difference that I am using Word2003. "Graham Mayor" wrote: Oops! By 'below' I meant in the revised macro Private Sub Document_New() Dim sCurrentPrinter As String sCurrentPrinter = Application.ActivePrinter ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" With Options .DefaultTray = "Tray 2" End With MsgBox Options.DefaultTray 'Application.PrintOut FileName:="" With Options .DefaultTray = "Use printer settings" End With ActivePrinter = sCurrentPrinter End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Graham Mayor wrote: What does the Message Box (below) report? If, as I suspect, it says Tray 2 - is there a Tray 2 associated with this printer or is it called something else? Try setting the tray assignment in the document's page setup (with the required printer active). AJ wrote: I am trying to use a macro on my mail merge template(Word2003) to set a specific print tray. I am calling the merge from access2003 and then am printing out the new merged document from a module in access. I am unsuccessful in trying to add a macro I found (www.gmayor.com/fax_from_word.htm) to place on my template so each document will print to a different tray. I don't know if I am doing something wrong or am missing something. I am able to run it from Word and it will switch the printer but not switch the tray. Then when I call the whole thing into Access it will switch printers but not print trays.I have placed the code on the mail merge template itself in the Document New, because to my limited knowledge this code is suppose to carry over to the merged documents.Is that true? I have the code below to view.Thank you ahead for any help. Private Sub Document_New() Dim sCurrentPrinter As String sCurrentPrinter = Application.ActivePrinter ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" With Options .DefaultTray = "Tray 2" End With Application.PrintOut FileName:="" With Options .DefaultTray = "Use printer settings" End With ActivePrinter = sCurrentPrinter End Sub |
#10
Posted to microsoft.public.word.mailmerge.fields,microsoft.public.word.vba.general
|
|||
|
|||
Setting a print tray
This is beginning to bug me to
I have posted a question in the vba forum (where I have also cross posted this message) so we shall see how widespread the issue is. In the meantime, I have come up with another workaround. With the printer in question set as the active printer, record a macro setting PageSetup to apply the trays there, instead of in Options. This will give you the tray ID numbers for that printer. You can then apply the pagesetup in the macro eg Sub HPPrint() Dim sPrinter As String With Dialogs(wdDialogFilePrintSetup) sPrinter = .Printer .Printer = "HP LaserJet 4050 Series PCL" .DoNotSetAsSysDefault = True .Execute With ActiveDocument.PageSetup .FirstPageTray = 260 .OtherPagesTray = 260 End With Dialogs(wdDialogFilePrint).Show .Printer = sPrinter .DoNotSetAsSysDefault = False .Execute End With End Sub This setting is actually retained in the document for when that printer is available and shouldn't affect the default Options. What's more to the point, it doesn't crash Word. The Options are stored in the Word settings sub key of the data key in the registry HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\W ord\Data this key setting is notoriously volatile in Word 2003. Others have said that this is attributable to the actions of wayward add-ins, but I have had the key fail to maintain settings when no add-ins are present, so I am not convinced with the diagnosis. It *may* be worth temporarily renaming the key to (say) oldsettings to see if it is any happier with a fresh copy of the sub key which Word will create if not present, but I am not confident that it will fix the problem. (You can delete the new sub key and rename the old one back again) to restore your settings if it doesn't improve things. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org AJ wrote: Thanks Mr. Mayor, I have been doing the backup and clearing out the trash files. Since this has been doing this for a couple of days now, I have become very proficient at backups... At least I can feel better at the fact that it isn't that Word just hates me and is bound and determined to drive me to the Psych Ward... I will look into the other site you suggested and see what to do from here. If you are able to figure anything out please let me know, this is going to bug me for days... Thanks, AJ "Graham Mayor" wrote: PS - Given the crashes, you should also see http://www.gmayor.com/what_to_do_when_word_crashes.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Graham Mayor wrote: This is all very odd? Testing here I too find that Word 2003 crashes if you change the default tray in vba with the example used. It certainly didn't do that when I wrote the web page One unsatisfactory workaround is to use the following code Dim sPrinter As String With Dialogs(wdDialogFilePrintSetup) sPrinter = .Printer .Printer = "\\OKKC405\IT_PS.PRINTERS" .DoNotSetAsSysDefault = True .Execute Dialogs(wdDialogFilePrint).Show .Printer = sPrinter .DoNotSetAsSysDefault = False .Execute End With which will at least pause while you change the tray manually. A more in depth look at controlling printers by VBA has been conducted by fellow MVP Jonathan West - see http://pubs.logicalexpressions.com/P...cle.asp?ID=116 AJ wrote: Also, I don't know if this makes any difference, but when I step through the macro, when it gets to the "With Options . defaulttray" line 1 of 2 things happens, either it goes through it without the normal pause you get when it is running a code. Like when it does the activeprinter line there is a pause while it runs the code and switches printers, but on this line and the other option line further in the code it either jumps right through it without any pause Or at other times when it gets to the option line the program freezes up and I get the "Word has encountered a problem and must shut down". I hope this makes since, basically it seems like it either skips over the "With options" or if it tries to run it I get the Message about encountering a problem. I don't know if it makes a difference that I am using Word2003. "Graham Mayor" wrote: Oops! By 'below' I meant in the revised macro Private Sub Document_New() Dim sCurrentPrinter As String sCurrentPrinter = Application.ActivePrinter ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" With Options .DefaultTray = "Tray 2" End With MsgBox Options.DefaultTray 'Application.PrintOut FileName:="" With Options .DefaultTray = "Use printer settings" End With ActivePrinter = sCurrentPrinter End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Graham Mayor wrote: What does the Message Box (below) report? If, as I suspect, it says Tray 2 - is there a Tray 2 associated with this printer or is it called something else? Try setting the tray assignment in the document's page setup (with the required printer active). AJ wrote: I am trying to use a macro on my mail merge template(Word2003) to set a specific print tray. I am calling the merge from access2003 and then am printing out the new merged document from a module in access. I am unsuccessful in trying to add a macro I found (www.gmayor.com/fax_from_word.htm) to place on my template so each document will print to a different tray. I don't know if I am doing something wrong or am missing something. I am able to run it from Word and it will switch the printer but not switch the tray. Then when I call the whole thing into Access it will switch printers but not print trays.I have placed the code on the mail merge template itself in the Document New, because to my limited knowledge this code is suppose to carry over to the merged documents.Is that true? I have the code below to view.Thank you ahead for any help. Private Sub Document_New() Dim sCurrentPrinter As String sCurrentPrinter = Application.ActivePrinter ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" With Options .DefaultTray = "Tray 2" End With Application.PrintOut FileName:="" With Options .DefaultTray = "Use printer settings" End With ActivePrinter = sCurrentPrinter End Sub |
#11
Posted to microsoft.public.word.mailmerge.fields,microsoft.public.word.vba.general
|
|||
|
|||
Setting a print tray
Based on Jonathan's experiments in the parallel vba forum thread (which is
not cross-posted to mailmergefields) Using the tray ID numbers does indeed work and you can therefore modify the original macro to employ DefaultTrayID as follows. I have left the messageboxes in so that you can review the assignments. Private Sub Document_New() Dim sCurrentPrinter As String Dim sTray As String sCurrentPrinter = Application.ActivePrinter With Options sTray = .DefaultTray ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" .DefaultTrayID = 260 'check tray2 ID as previously discussed. MsgBox ActivePrinter & vbCr & .DefaultTray Application.PrintOut FileName:="" ActivePrinter = sCurrentPrinter .DefaultTray = sTray MsgBox ActivePrinter & vbCr & .DefaultTray End With End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Graham Mayor wrote: This is beginning to bug me to I have posted a question in the vba forum (where I have also cross posted this message) so we shall see how widespread the issue is. In the meantime, I have come up with another workaround. With the printer in question set as the active printer, record a macro setting PageSetup to apply the trays there, instead of in Options. This will give you the tray ID numbers for that printer. You can then apply the pagesetup in the macro eg Sub HPPrint() Dim sPrinter As String With Dialogs(wdDialogFilePrintSetup) sPrinter = .Printer .Printer = "HP LaserJet 4050 Series PCL" .DoNotSetAsSysDefault = True .Execute With ActiveDocument.PageSetup .FirstPageTray = 260 .OtherPagesTray = 260 End With Dialogs(wdDialogFilePrint).Show .Printer = sPrinter .DoNotSetAsSysDefault = False .Execute End With End Sub This setting is actually retained in the document for when that printer is available and shouldn't affect the default Options. What's more to the point, it doesn't crash Word. The Options are stored in the Word settings sub key of the data key in the registry HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\W ord\Data this key setting is notoriously volatile in Word 2003. Others have said that this is attributable to the actions of wayward add-ins, but I have had the key fail to maintain settings when no add-ins are present, so I am not convinced with the diagnosis. It *may* be worth temporarily renaming the key to (say) oldsettings to see if it is any happier with a fresh copy of the sub key which Word will create if not present, but I am not confident that it will fix the problem. (You can delete the new sub key and rename the old one back again) to restore your settings if it doesn't improve things. AJ wrote: Thanks Mr. Mayor, I have been doing the backup and clearing out the trash files. Since this has been doing this for a couple of days now, I have become very proficient at backups... At least I can feel better at the fact that it isn't that Word just hates me and is bound and determined to drive me to the Psych Ward... I will look into the other site you suggested and see what to do from here. If you are able to figure anything out please let me know, this is going to bug me for days... Thanks, AJ "Graham Mayor" wrote: PS - Given the crashes, you should also see http://www.gmayor.com/what_to_do_when_word_crashes.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Graham Mayor wrote: This is all very odd? Testing here I too find that Word 2003 crashes if you change the default tray in vba with the example used. It certainly didn't do that when I wrote the web page One unsatisfactory workaround is to use the following code Dim sPrinter As String With Dialogs(wdDialogFilePrintSetup) sPrinter = .Printer .Printer = "\\OKKC405\IT_PS.PRINTERS" .DoNotSetAsSysDefault = True .Execute Dialogs(wdDialogFilePrint).Show .Printer = sPrinter .DoNotSetAsSysDefault = False .Execute End With which will at least pause while you change the tray manually. A more in depth look at controlling printers by VBA has been conducted by fellow MVP Jonathan West - see http://pubs.logicalexpressions.com/P...cle.asp?ID=116 AJ wrote: Also, I don't know if this makes any difference, but when I step through the macro, when it gets to the "With Options . defaulttray" line 1 of 2 things happens, either it goes through it without the normal pause you get when it is running a code. Like when it does the activeprinter line there is a pause while it runs the code and switches printers, but on this line and the other option line further in the code it either jumps right through it without any pause Or at other times when it gets to the option line the program freezes up and I get the "Word has encountered a problem and must shut down". I hope this makes since, basically it seems like it either skips over the "With options" or if it tries to run it I get the Message about encountering a problem. I don't know if it makes a difference that I am using Word2003. "Graham Mayor" wrote: Oops! By 'below' I meant in the revised macro Private Sub Document_New() Dim sCurrentPrinter As String sCurrentPrinter = Application.ActivePrinter ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" With Options .DefaultTray = "Tray 2" End With MsgBox Options.DefaultTray 'Application.PrintOut FileName:="" With Options .DefaultTray = "Use printer settings" End With ActivePrinter = sCurrentPrinter End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Graham Mayor wrote: What does the Message Box (below) report? If, as I suspect, it says Tray 2 - is there a Tray 2 associated with this printer or is it called something else? Try setting the tray assignment in the document's page setup (with the required printer active). AJ wrote: I am trying to use a macro on my mail merge template(Word2003) to set a specific print tray. I am calling the merge from access2003 and then am printing out the new merged document from a module in access. I am unsuccessful in trying to add a macro I found (www.gmayor.com/fax_from_word.htm) to place on my template so each document will print to a different tray. I don't know if I am doing something wrong or am missing something. I am able to run it from Word and it will switch the printer but not switch the tray. Then when I call the whole thing into Access it will switch printers but not print trays.I have placed the code on the mail merge template itself in the Document New, because to my limited knowledge this code is suppose to carry over to the merged documents.Is that true? I have the code below to view.Thank you ahead for any help. Private Sub Document_New() Dim sCurrentPrinter As String sCurrentPrinter = Application.ActivePrinter ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" With Options .DefaultTray = "Tray 2" End With Application.PrintOut FileName:="" With Options .DefaultTray = "Use printer settings" End With ActivePrinter = sCurrentPrinter End Sub |
#12
Posted to microsoft.public.word.mailmerge.fields,microsoft.public.word.vba.general
|
|||
|
|||
Setting a print tray
Mr. Mayor,
Thank you so much for all the help. I was able to accomplish this finally by using your suggestion below, ie.. DefaultTrayID instead of DefaultTray. Very strange that this was works fine and the other shuts down Word...Oh well that is why we will never be out of jobs...Thanks again for all the help. AJ "Graham Mayor" wrote: Based on Jonathan's experiments in the parallel vba forum thread (which is not cross-posted to mailmergefields) Using the tray ID numbers does indeed work and you can therefore modify the original macro to employ DefaultTrayID as follows. I have left the messageboxes in so that you can review the assignments. Private Sub Document_New() Dim sCurrentPrinter As String Dim sTray As String sCurrentPrinter = Application.ActivePrinter With Options sTray = .DefaultTray ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" .DefaultTrayID = 260 'check tray2 ID as previously discussed. MsgBox ActivePrinter & vbCr & .DefaultTray Application.PrintOut FileName:="" ActivePrinter = sCurrentPrinter .DefaultTray = sTray MsgBox ActivePrinter & vbCr & .DefaultTray End With End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Graham Mayor wrote: This is beginning to bug me to I have posted a question in the vba forum (where I have also cross posted this message) so we shall see how widespread the issue is. In the meantime, I have come up with another workaround. With the printer in question set as the active printer, record a macro setting PageSetup to apply the trays there, instead of in Options. This will give you the tray ID numbers for that printer. You can then apply the pagesetup in the macro eg Sub HPPrint() Dim sPrinter As String With Dialogs(wdDialogFilePrintSetup) sPrinter = .Printer .Printer = "HP LaserJet 4050 Series PCL" .DoNotSetAsSysDefault = True .Execute With ActiveDocument.PageSetup .FirstPageTray = 260 .OtherPagesTray = 260 End With Dialogs(wdDialogFilePrint).Show .Printer = sPrinter .DoNotSetAsSysDefault = False .Execute End With End Sub This setting is actually retained in the document for when that printer is available and shouldn't affect the default Options. What's more to the point, it doesn't crash Word. The Options are stored in the Word settings sub key of the data key in the registry HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\W ord\Data this key setting is notoriously volatile in Word 2003. Others have said that this is attributable to the actions of wayward add-ins, but I have had the key fail to maintain settings when no add-ins are present, so I am not convinced with the diagnosis. It *may* be worth temporarily renaming the key to (say) oldsettings to see if it is any happier with a fresh copy of the sub key which Word will create if not present, but I am not confident that it will fix the problem. (You can delete the new sub key and rename the old one back again) to restore your settings if it doesn't improve things. AJ wrote: Thanks Mr. Mayor, I have been doing the backup and clearing out the trash files. Since this has been doing this for a couple of days now, I have become very proficient at backups... At least I can feel better at the fact that it isn't that Word just hates me and is bound and determined to drive me to the Psych Ward... I will look into the other site you suggested and see what to do from here. If you are able to figure anything out please let me know, this is going to bug me for days... Thanks, AJ "Graham Mayor" wrote: PS - Given the crashes, you should also see http://www.gmayor.com/what_to_do_when_word_crashes.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Graham Mayor wrote: This is all very odd? Testing here I too find that Word 2003 crashes if you change the default tray in vba with the example used. It certainly didn't do that when I wrote the web page One unsatisfactory workaround is to use the following code Dim sPrinter As String With Dialogs(wdDialogFilePrintSetup) sPrinter = .Printer .Printer = "\\OKKC405\IT_PS.PRINTERS" .DoNotSetAsSysDefault = True .Execute Dialogs(wdDialogFilePrint).Show .Printer = sPrinter .DoNotSetAsSysDefault = False .Execute End With which will at least pause while you change the tray manually. A more in depth look at controlling printers by VBA has been conducted by fellow MVP Jonathan West - see http://pubs.logicalexpressions.com/P...cle.asp?ID=116 AJ wrote: Also, I don't know if this makes any difference, but when I step through the macro, when it gets to the "With Options . defaulttray" line 1 of 2 things happens, either it goes through it without the normal pause you get when it is running a code. Like when it does the activeprinter line there is a pause while it runs the code and switches printers, but on this line and the other option line further in the code it either jumps right through it without any pause Or at other times when it gets to the option line the program freezes up and I get the "Word has encountered a problem and must shut down". I hope this makes since, basically it seems like it either skips over the "With options" or if it tries to run it I get the Message about encountering a problem. I don't know if it makes a difference that I am using Word2003. "Graham Mayor" wrote: Oops! By 'below' I meant in the revised macro Private Sub Document_New() Dim sCurrentPrinter As String sCurrentPrinter = Application.ActivePrinter ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" With Options .DefaultTray = "Tray 2" End With MsgBox Options.DefaultTray 'Application.PrintOut FileName:="" With Options .DefaultTray = "Use printer settings" End With ActivePrinter = sCurrentPrinter End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Graham Mayor wrote: What does the Message Box (below) report? If, as I suspect, it says Tray 2 - is there a Tray 2 associated with this printer or is it called something else? Try setting the tray assignment in the document's page setup (with the required printer active). AJ wrote: I am trying to use a macro on my mail merge template(Word2003) to set a specific print tray. I am calling the merge from access2003 and then am printing out the new merged document from a module in access. I am unsuccessful in trying to add a macro I found (www.gmayor.com/fax_from_word.htm) to place on my template so each document will print to a different tray. I don't know if I am doing something wrong or am missing something. I am able to run it from Word and it will switch the printer but not switch the tray. Then when I call the whole thing into Access it will switch printers but not print trays.I have placed the code on the mail merge template itself in the Document New, because to my limited knowledge this code is suppose to carry over to the merged documents.Is that true? I have the code below to view.Thank you ahead for any help. Private Sub Document_New() Dim sCurrentPrinter As String sCurrentPrinter = Application.ActivePrinter ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" With Options .DefaultTray = "Tray 2" End With Application.PrintOut FileName:="" With Options .DefaultTray = "Use printer settings" End With ActivePrinter = sCurrentPrinter End Sub |
#13
Posted to microsoft.public.word.mailmerge.fields,microsoft.public.word.vba.general
|
|||
|
|||
Setting a print tray
I have now modified the tray selection routine on my web site
-- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org AJ wrote: Mr. Mayor, Thank you so much for all the help. I was able to accomplish this finally by using your suggestion below, ie.. DefaultTrayID instead of DefaultTray. Very strange that this was works fine and the other shuts down Word...Oh well that is why we will never be out of jobs...Thanks again for all the help. AJ "Graham Mayor" wrote: Based on Jonathan's experiments in the parallel vba forum thread (which is not cross-posted to mailmergefields) Using the tray ID numbers does indeed work and you can therefore modify the original macro to employ DefaultTrayID as follows. I have left the messageboxes in so that you can review the assignments. Private Sub Document_New() Dim sCurrentPrinter As String Dim sTray As String sCurrentPrinter = Application.ActivePrinter With Options sTray = .DefaultTray ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" .DefaultTrayID = 260 'check tray2 ID as previously discussed. MsgBox ActivePrinter & vbCr & .DefaultTray Application.PrintOut FileName:="" ActivePrinter = sCurrentPrinter .DefaultTray = sTray MsgBox ActivePrinter & vbCr & .DefaultTray End With End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Graham Mayor wrote: This is beginning to bug me to I have posted a question in the vba forum (where I have also cross posted this message) so we shall see how widespread the issue is. In the meantime, I have come up with another workaround. With the printer in question set as the active printer, record a macro setting PageSetup to apply the trays there, instead of in Options. This will give you the tray ID numbers for that printer. You can then apply the pagesetup in the macro eg Sub HPPrint() Dim sPrinter As String With Dialogs(wdDialogFilePrintSetup) sPrinter = .Printer .Printer = "HP LaserJet 4050 Series PCL" .DoNotSetAsSysDefault = True .Execute With ActiveDocument.PageSetup .FirstPageTray = 260 .OtherPagesTray = 260 End With Dialogs(wdDialogFilePrint).Show .Printer = sPrinter .DoNotSetAsSysDefault = False .Execute End With End Sub This setting is actually retained in the document for when that printer is available and shouldn't affect the default Options. What's more to the point, it doesn't crash Word. The Options are stored in the Word settings sub key of the data key in the registry HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\W ord\Data this key setting is notoriously volatile in Word 2003. Others have said that this is attributable to the actions of wayward add-ins, but I have had the key fail to maintain settings when no add-ins are present, so I am not convinced with the diagnosis. It *may* be worth temporarily renaming the key to (say) oldsettings to see if it is any happier with a fresh copy of the sub key which Word will create if not present, but I am not confident that it will fix the problem. (You can delete the new sub key and rename the old one back again) to restore your settings if it doesn't improve things. AJ wrote: Thanks Mr. Mayor, I have been doing the backup and clearing out the trash files. Since this has been doing this for a couple of days now, I have become very proficient at backups... At least I can feel better at the fact that it isn't that Word just hates me and is bound and determined to drive me to the Psych Ward... I will look into the other site you suggested and see what to do from here. If you are able to figure anything out please let me know, this is going to bug me for days... Thanks, AJ "Graham Mayor" wrote: PS - Given the crashes, you should also see http://www.gmayor.com/what_to_do_when_word_crashes.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Graham Mayor wrote: This is all very odd? Testing here I too find that Word 2003 crashes if you change the default tray in vba with the example used. It certainly didn't do that when I wrote the web page One unsatisfactory workaround is to use the following code Dim sPrinter As String With Dialogs(wdDialogFilePrintSetup) sPrinter = .Printer .Printer = "\\OKKC405\IT_PS.PRINTERS" .DoNotSetAsSysDefault = True .Execute Dialogs(wdDialogFilePrint).Show .Printer = sPrinter .DoNotSetAsSysDefault = False .Execute End With which will at least pause while you change the tray manually. A more in depth look at controlling printers by VBA has been conducted by fellow MVP Jonathan West - see http://pubs.logicalexpressions.com/P...cle.asp?ID=116 AJ wrote: Also, I don't know if this makes any difference, but when I step through the macro, when it gets to the "With Options . defaulttray" line 1 of 2 things happens, either it goes through it without the normal pause you get when it is running a code. Like when it does the activeprinter line there is a pause while it runs the code and switches printers, but on this line and the other option line further in the code it either jumps right through it without any pause Or at other times when it gets to the option line the program freezes up and I get the "Word has encountered a problem and must shut down". I hope this makes since, basically it seems like it either skips over the "With options" or if it tries to run it I get the Message about encountering a problem. I don't know if it makes a difference that I am using Word2003. "Graham Mayor" wrote: Oops! By 'below' I meant in the revised macro Private Sub Document_New() Dim sCurrentPrinter As String sCurrentPrinter = Application.ActivePrinter ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" With Options .DefaultTray = "Tray 2" End With MsgBox Options.DefaultTray 'Application.PrintOut FileName:="" With Options .DefaultTray = "Use printer settings" End With ActivePrinter = sCurrentPrinter End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Graham Mayor wrote: What does the Message Box (below) report? If, as I suspect, it says Tray 2 - is there a Tray 2 associated with this printer or is it called something else? Try setting the tray assignment in the document's page setup (with the required printer active). AJ wrote: I am trying to use a macro on my mail merge template(Word2003) to set a specific print tray. I am calling the merge from access2003 and then am printing out the new merged document from a module in access. I am unsuccessful in trying to add a macro I found (www.gmayor.com/fax_from_word.htm) to place on my template so each document will print to a different tray. I don't know if I am doing something wrong or am missing something. I am able to run it from Word and it will switch the printer but not switch the tray. Then when I call the whole thing into Access it will switch printers but not print trays.I have placed the code on the mail merge template itself in the Document New, because to my limited knowledge this code is suppose to carry over to the merged documents.Is that true? I have the code below to view.Thank you ahead for any help. Private Sub Document_New() Dim sCurrentPrinter As String sCurrentPrinter = Application.ActivePrinter ActivePrinter = "\\OKKC405\IT_PS.PRINTERS" With Options .DefaultTray = "Tray 2" End With Application.PrintOut FileName:="" With Options .DefaultTray = "Use printer settings" End With ActivePrinter = sCurrentPrinter End Sub |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Printing Tray Woes - Getting Word to Print to Correct paper tray | Microsoft Word Help | |||
Unable to print from 2nd tray | Microsoft Word Help | |||
Setting default tray for label printing in Word 2000 | Microsoft Word Help | |||
Print mailmerge with pg 1 to tray 1 and pg 2 to tray 2. Ideas? | Mailmerge | |||
Laserjet 4 and MS Word prints only from main tray. Can't print from MP tray. | Microsoft Word Help |