Can I programmatically control the Rotate 180 Degrees option in the HP printer driver settings using VBA?

I am trying to turn the Rotate 180 degree setting on and off for an HP Laser Inkjet Printer (4200/4350) using a duplexer. In the meantime, there is no need to worry about it.

The business has a requirement to "print on both sides", for maximum control I would like to be able to manipulate during printing (via print macros) whether duplex printing is allowed for each of the different types, document the business with.

I can manage tray assignments, order prints, and turn duplex on and off. However, can't figure out how to control the rotation parameter (turn it on and off).

Any solutions available other than blanket enable this option on the print server for all documents / users?

Great importance.

0


source to share


2 answers


Perhaps the HP duplex option can be controlled with:

Printer Object: VBA Access 2003 Language Reference ( http://msdn.microsoft.com/en-us/library/aa223133(office.11).aspx )



More specific:

Duplex Property ( http://msdn.microsoft.com/en-us/library/aa195860(office.11).aspx )

+1


source


The COM interface is what you need. The python code for changing the tray is below: VB follows the same basic steps.

import win32print
PRINTER_DEFAULTS = {"DesiredAccess":win32print.PRINTER_ALL_ACCESS}
pHandle = win32print.OpenPrinter('PRINTERNAME', PRINTER_DEFAULTS)
properties = win32print.GetPrinter(pHandle, 2) #get the properties
pDevModeObj = properties["pDevMode"] #get the devmode
pDevModeObj.DefaultSource = tray_three #change some sort of setting... this case is the tray
properties["pDevMode"]=pDevModeObj #write the devmode back to properties
win32print.SetPrinter(pHandle,2,properties,0) #save the properties to the printer

      



Of course, you can just change the printer settings via vba in word. If you are using Excel or any other office product, it will not work.

+1


source







All Articles