Hello,
I have several network printers that I need to print to based on what is going on in the application. I tried to create printer objects for each of the different printers and just do printerobject.print but that didn't work ... It creates the object with all of the properties of that printer but it just won't execute the Print or EndDoc methods. Now I am trying to store the default printer in an object, change Printer to which ever printer I need it to be then change it back. But there are two problems: 1. it changed the global object (I am calling it gDefaultPrinter) to the object I am trying to print to; 2. If you try to set the Printer object to a value the same as itself, it generates an error
I have in the Common module:
Global gErrorsPrinter As Printer
Global gDefaultPrinter As Printer
on start up:
'** Capture Default
Set gDefaultPrinter = Printer
'** Establish Errors printer
For Each cIn Printers
If TestPrt.DeviceName = gstrOverrideErrPrinter Then
Set gErrorsPrinter = TestPrt
Exit For '** Found it
End If
Next
This all seems to work fine. If I print devicenames in the immediate window they are all what I want them to be.
later, if there is an error I need to print
Set Printer = gErrorsPrinter
Printer.Print TXT
Printer.EndDoc
Set Printer = gDefaultPrinter
It fails on the last line and all 3 printer objects are the ErrorsPrinter.
If I do gErrorsPrinter.Print, I get object not supported errors.
Any ideas?
Thanks in adavance
I have several network printers that I need to print to based on what is going on in the application. I tried to create printer objects for each of the different printers and just do printerobject.print but that didn't work ... It creates the object with all of the properties of that printer but it just won't execute the Print or EndDoc methods. Now I am trying to store the default printer in an object, change Printer to which ever printer I need it to be then change it back. But there are two problems: 1. it changed the global object (I am calling it gDefaultPrinter) to the object I am trying to print to; 2. If you try to set the Printer object to a value the same as itself, it generates an error
I have in the Common module:
Global gErrorsPrinter As Printer
Global gDefaultPrinter As Printer
on start up:
'** Capture Default
Set gDefaultPrinter = Printer
'** Establish Errors printer
For Each cIn Printers
If TestPrt.DeviceName = gstrOverrideErrPrinter Then
Set gErrorsPrinter = TestPrt
Exit For '** Found it
End If
Next
This all seems to work fine. If I print devicenames in the immediate window they are all what I want them to be.
later, if there is an error I need to print
Set Printer = gErrorsPrinter
Printer.Print TXT
Printer.EndDoc
Set Printer = gDefaultPrinter
It fails on the last line and all 3 printer objects are the ErrorsPrinter.
If I do gErrorsPrinter.Print, I get object not supported errors.
Any ideas?
Thanks in adavance