G
Graham Mayor
For some time now I have had some printer switching routines detailed on my
web site http://www.gmayor.com/fax_from_word.htm and they have always worked
in the past ... until recently when I responded to a question in the mail
merge group to a user who found that Word crashed when the tray options were
selected. The following sample code should show the problem (change the
printer name to a valid printer that is not the default printer and which
has a tray 2 assignment available:
Sub HPPrint()
Dim sPrinter As String
Dim sTray As String
sTray = Options.DefaultTray
With Dialogs(wdDialogFilePrintSetup)
sPrinter = .Printer
.Printer = "HP LaserJet 4050 Series PCL"
.DoNotSetAsSysDefault = True
.Execute
End With
Options.DefaultTray = "Tray2"
MsgBox ActivePrinter & vbCr & Options.DefaultTray
'Dialogs(wdDialogFilePrint).Show
With Dialogs(wdDialogFilePrintSetup)
.Printer = sPrinter
.DoNotSetAsSysDefault = False
.Execute
End With
Options.DefaultTray = sTray
MsgBox ActivePrinter & vbCr & Options.DefaultTray
End Sub
I find this invariably crashes Word 2003 (sp2 and sp3) and in Word 2007 the
line
Options.DefaultTray = "Tray2"
is ignored
Even using the simpler
Sub HPPrint()
Dim sPrinter As String
Dim sTray As String
sTray = Options.DefaultTray
sPrinter = ActivePrinter
ActivePrinter = "HP LaserJet 4050 Series PCL"
Options.DefaultTray = "Tray2"
MsgBox ActivePrinter & vbCr & Options.DefaultTray
ActivePrinter = sPrinter
Options.DefaultTray = sTray
MsgBox ActivePrinter & vbCr & Options.DefaultTray
End Sub
the same results apply?
I had suspected Acrobat may have been the problem, but I uninstalled that
and the problem remains.
Is anyone else experiencing this problem?
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
web site http://www.gmayor.com/fax_from_word.htm and they have always worked
in the past ... until recently when I responded to a question in the mail
merge group to a user who found that Word crashed when the tray options were
selected. The following sample code should show the problem (change the
printer name to a valid printer that is not the default printer and which
has a tray 2 assignment available:
Sub HPPrint()
Dim sPrinter As String
Dim sTray As String
sTray = Options.DefaultTray
With Dialogs(wdDialogFilePrintSetup)
sPrinter = .Printer
.Printer = "HP LaserJet 4050 Series PCL"
.DoNotSetAsSysDefault = True
.Execute
End With
Options.DefaultTray = "Tray2"
MsgBox ActivePrinter & vbCr & Options.DefaultTray
'Dialogs(wdDialogFilePrint).Show
With Dialogs(wdDialogFilePrintSetup)
.Printer = sPrinter
.DoNotSetAsSysDefault = False
.Execute
End With
Options.DefaultTray = sTray
MsgBox ActivePrinter & vbCr & Options.DefaultTray
End Sub
I find this invariably crashes Word 2003 (sp2 and sp3) and in Word 2007 the
line
Options.DefaultTray = "Tray2"
is ignored
Even using the simpler
Sub HPPrint()
Dim sPrinter As String
Dim sTray As String
sTray = Options.DefaultTray
sPrinter = ActivePrinter
ActivePrinter = "HP LaserJet 4050 Series PCL"
Options.DefaultTray = "Tray2"
MsgBox ActivePrinter & vbCr & Options.DefaultTray
ActivePrinter = sPrinter
Options.DefaultTray = sTray
MsgBox ActivePrinter & vbCr & Options.DefaultTray
End Sub
the same results apply?
I had suspected Acrobat may have been the problem, but I uninstalled that
and the problem remains.
Is anyone else experiencing this problem?
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>