How to set the active printer in Publisher 2007?

G

Geekgrrl71

I am automating printing from Publisher 2007 using C# and reflection (for
late binding). I need to tell Publisher to print to a specific printer.

With Publisher 2003, we could do this by setting Application.ActivePrinter
as the name of the printer we want and also setting that printer as the
system default printer.

This option is gone with the Pub2007 model, replaced with the
InstalledPrinters collection and the Printer object. From the docs it looks
like I should be able to set my "ActivePrinter" by looping through the
collection and setting the Printer.IsActivePrinter flag to my printer and
flipping the IsActivePrinter flag for the original active printer.

When I try to set the IsActivePrinter property for any printer in the
collection (this is a read/write boolean property) I get E_INVALIDARG. The
printerItem object is valid, Ijust retrieved the name of the printer from it
above my call to "IsActivePrinter".

Here is my code:
propertyParameter[0] = true;
printerItem.GetType().InvokeMember("IsActivePrinter",
BindingFlags.SetProperty, null, printerItem, propertyParameter);

Has anyone been able to do this? Is there a different way to set the active
printer?

Thanks.
Geekgrrl
 
G

Geekgrrl71

Aha! As usual, I solve my problem right after I post.

You only need to set the IsActivePrinter flag to true on the printer you
wish to be the default or active printer; you don't need to change any of the
settings in the other printer objects...

*sigh* If only I had realized that 4 hours ago!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top