Hi All
Word 2003, XP
Networked printers with local drivers.
I'm trying to query a printer to establish if duplex is available.
Everything I've researched points me in the direction of DeviceCapabilities.
However, I can't get it to work. I've included two calls for comparison.
The iBins call is working and correctly returns a value dependent on the
printer provided. The iDuplex call returns -1 which indicates a failed call.
Any assistance is greatly appreciated.
Private Const DC_BINS = 6
Private Const DM_DUPLEX = &H1000
Private Declare Function DeviceCapabilities Lib "winspool.drv" _
Alias "DeviceCapabilitiesA" (ByVal lpDeviceName As String, _
ByVal lpPort As String, ByVal iIndex As Long, lpOutput As Any, _
ByVal dev As Long) As Long
iBins = DeviceCapabilities(sCurrentPrinter, sPort, _
DC_BINS, ByVal vbNullString, 0)
iDuplex = DeviceCapabilities(sCurrentPrinter, sPort, _
DM_DUPLEX, ByVal vbNullString, 0)

Signature
Cheers
Carolin
Jonathan West - 21 Aug 2007 09:06 GMT
> Hi All
>
[quoted text clipped - 22 lines]
> iDuplex = DeviceCapabilities(sCurrentPrinter, sPort, _
> DM_DUPLEX, ByVal vbNullString, 0)
Controlling the Printer from Word VBA
Part 2: Using VBA to control Duplex, Color Mode and Print Quality
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=116
As far as I can remember, the only way to know if the printer has duplex
capability is to to set the printer to duplex, and then read the duplex
setting back and see if it has stuck.

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Carolin - 22 Aug 2007 00:44 GMT
Hi Jonathan
Unfortunately this didn't work. My test printer was not capable of duplex
printing. I set it to duplex and then read the property back. It returned a
value of 2, indicating it was set to duplex. When I looked at the properties
of the printer, it was set to single sided and a message was displayed that
advised me that it was switched to single. I OK'd the message and the
properties appeared to be OK. I re-ran my code to return the property value
(I did not reset it to duplex merely read back the value). It was still
returning 2. The properties dialog again displayed the message.
At least if an error was returned when setting duplex I could trap it. But
it doesn't. Very frustrating.

Signature
Cheers
Carolin
> > Hi All
> >
[quoted text clipped - 30 lines]
> capability is to to set the printer to duplex, and then read the duplex
> setting back and see if it has stuck.
Jonathan West - 22 Aug 2007 10:15 GMT
> Hi Jonathan
>
[quoted text clipped - 14 lines]
> But
> it doesn't. Very frustrating.
Unfortunately, if the printer driver lies to you, there isn't much you can
do about it.

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Carolin - 23 Aug 2007 00:10 GMT
Yeah I figured this might be the outcome. Thanks for you help Jonathan

Signature
Cheers
Carolin
> > Hi Jonathan
> >
[quoted text clipped - 17 lines]
> Unfortunately, if the printer driver lies to you, there isn't much you can
> do about it.
Carolin - 23 Aug 2007 00:58 GMT
Jonathan, I've had success!!!!
By setting the Duplex constant to 7 rather than &H1000 I was able to return
the duplex capability. I haven't tested that the new constant setting will
work with the property calls, but I'm happy to set two constants if I have to.

Signature
Cheers
Carolin
> > Hi Jonathan
> >
[quoted text clipped - 17 lines]
> Unfortunately, if the printer driver lies to you, there isn't much you can
> do about it.