changing windows default printer using vba6

February 8, 2011 at 06:17:06
Specs: Windows XP
I have a VB program that connects CorelDraw 9 with Excel 2000. Corel is totally controlled using VBA code in Excel. To be able to print a drawing to another printer, using Excel VBA, I needt to change the Windows default printer because this is, as far as I know, not possible in Corel9 VBA code. For example, in Excel VBA you can just type the code "Application.ActivePrinter = "PrinterName". This is not possible in Corel9 VBA. I need to change the windows default printer using Excel VBA and restart Corel using Excel VBA. Then, after restarting Corel, the default and active printer in Corel is the one I need.

See More: changing windows default printer using vba6

February 9, 2011 at 12:24:07
I do not think you can set that in VBA, but I could be wrong.

However, you can prompt the user in VBA for the printer dialog box so that the choice can be made.

I think, if memory serves, it is something like ....


I'm learning.

Report •

February 9, 2011 at 12:58:36
Is this what you are looking for?

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •

February 9, 2011 at 23:16:36
Hi all who responded,
Recently I found elsewhere on the net how to do it:

Dim WshNetwork

Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.SetDefaultPrinter "\\<ServerName>\<PrinterName>"

WshNetwork.SetDefaultPrinter "\\FS01\- Lexmark_Office03 -"

Just two simple lines of code and it works perfectly fine. Don't forget to set it back to the "usual" default printer afterwards.......

Thanks for your support.

Report •
Related Solutions

Ask Question