G
Galin Iliev
Hello folks,
I am using MS Word and Excel automating to perform some specific tasks.
For these needs I have to print Document and Workbook on specific system
printer.
there is no problem with MS Word documents as I change it with this code:
oWordApp.WordBasic.FilePrintSetup Printer:=sNEWPrinter,
DoNotSetAsSysDefault:=1
Unfotunately, I found there is no such alternative in MS Excel so I have
tested these ways (in VB6 and MS Excel 2002):
oExcelApp.ActivePrinter = "IBM Graphics"
and
oExcelApp.ActivePrinter = "IBM Graphics on PRN1:"
and
oExcelApp.ActiveWorkbook.ActiveSheet.Printout activeprinter:="IBM Graphics
on PRN1:"
and
oExcelApp.ActiveWorkbook.ActiveSheet.Printout activeprinter:="IBM Graphics"
but all of them returned "Application-defined or object-defined error"
or more specific: "Method 'Active printer' of object'_ Application failed
error" in MS Excel 2002 VBA
I am able to change system default printer using WIN API but this is not
desirable as users could use my program as background and start printing job
by other applciation.
Thank you in advance
Galin Iliev
MCSD
Software Consulting Services
I am using MS Word and Excel automating to perform some specific tasks.
For these needs I have to print Document and Workbook on specific system
printer.
there is no problem with MS Word documents as I change it with this code:
oWordApp.WordBasic.FilePrintSetup Printer:=sNEWPrinter,
DoNotSetAsSysDefault:=1
Unfotunately, I found there is no such alternative in MS Excel so I have
tested these ways (in VB6 and MS Excel 2002):
oExcelApp.ActivePrinter = "IBM Graphics"
and
oExcelApp.ActivePrinter = "IBM Graphics on PRN1:"
and
oExcelApp.ActiveWorkbook.ActiveSheet.Printout activeprinter:="IBM Graphics
on PRN1:"
and
oExcelApp.ActiveWorkbook.ActiveSheet.Printout activeprinter:="IBM Graphics"
but all of them returned "Application-defined or object-defined error"
or more specific: "Method 'Active printer' of object'_ Application failed
error" in MS Excel 2002 VBA
I am able to change system default printer using WIN API but this is not
desirable as users could use my program as background and start printing job
by other applciation.
Thank you in advance
Galin Iliev
MCSD
Software Consulting Services