September 20th, 1999, 01:49 PM
In VB, you can change the default printer by reassigning the Printer object. However, that only changes the default printer for that application. I am creating an Active X control to be used with other applications (such as Access) that allows changing the default printer. However, reassigning the Printer object no longer works. More precisely, it works inside the control, but not outside the control. The question is, how can I make the control change the system printer for the application using the control?
Here is an example to demonstrate what I'm talking about:
'the following is code inside the control
debug.print Printer.DevName 'displays name of default printer, "printer1"
set Printer = Printers(2) 'changes the default printer to printer number 2
debug.print Printer.DevName 'displays name of default printer, "printer2"
'now exit control code
'execute code of containing program, such as Access or a VB app
debug.printer Printer.DevName 'displays original printer name, "pritner1"
One solution for this is to change the default printer for the entire system. Users can do this manually (e.g., in the control panel), but I need to do it programmatically. Only I can't find an API for this. Anyone got a clue?
Here is an example to demonstrate what I'm talking about:
'the following is code inside the control
debug.print Printer.DevName 'displays name of default printer, "printer1"
set Printer = Printers(2) 'changes the default printer to printer number 2
debug.print Printer.DevName 'displays name of default printer, "printer2"
'now exit control code
'execute code of containing program, such as Access or a VB app
debug.printer Printer.DevName 'displays original printer name, "pritner1"
One solution for this is to change the default printer for the entire system. Users can do this manually (e.g., in the control panel), but I need to do it programmatically. Only I can't find an API for this. Anyone got a clue?