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
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