VBA Duplexing won't reset

S

Sasquatch

I'm back again :(

As previously suggested, I've used the code from
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=116 to control
the duplex property of my printer. It will in fact turn on the duplex option
as intended, but once it does so it won't turn it back off, even though it
says it did (through message box responses). Here is the code from my
Document_Open and _Close events:
========================================
Private lngOrigSetting As Long
Private boolOptionChanged As Boolean

Private Sub Document_Open()
'* retrieve the original duplex setting
lngOrigSetting = GetDuplex
MsgBox "Retrieved: " & lngOrigSetting

'* turn on duplex if it isn't already on
If lngOrigSetting <> 2 Then
SetDuplex 2
boolOptionChanged = True
MsgBox "After setting, retrieved: " & GetDuplex
Else
boolOptionChanged = False
MsgBox "Duplex already on"
End If
End Sub


Private Sub Document_Close()
Dim lngCurrSetting As Long

If boolOptionChanged Then
'* retrieve the current setting
lngCurrSetting = GetDuplex
MsgBox "Retrieved: " & lngCurrSetting

'* if current setting <> original setting then reset it
If lngCurrSetting <> lngOrigSetting Then
MsgBox "Resetting to: " & lngOrigSetting
SetDuplex lngOrigSetting
MsgBox "After setting, retrieved: " & GetDuplex
End If
End If
End Sub
========================================

So, when I open the document the message boxes tell me:
Retrieved: 1
After setting, retrieved: 2

If I check the File/Print.../Properties the duplex option is on and it will
print double sided. When I close the document the message boxes tell me:
Retrieved: 2
Resetting to: 1
After setting, retrieved: 1

Now, if I reopen the document and close it I get the same messages, telling
me it is turned on and back off, *BUT* if I open any other file (Word, Excel,
whatever) it will still duplex print it. If I open the document it will give
me the same series of messages...turned on...turned off.

I tried it on all 3 of our networked printers (all 3 are RICOH Aficio 1075
PCL 6) and I get the same results on each printer. If I go to the printer
window from the control panel and check the printer's properties it will say
that duplex is off but when I reopen anything it will still print it duplexed.

Any help would be greatly appreciated...I've been at this for a few days.
Ultimately I'd like to use the above code for documents with more than 5
pages so that they automatically duplex print w/o any user interaction.

Thanks in advance...
 
G

GeorgeW

Is your code in NORMAL.dot?

That would explain why duplexing is always turning on everytime you open a
word document.

It shouldn't affect Excel or other documents though...
 
S

Sasquatch

GeorgeW said:
Is your code in NORMAL.dot?
That would explain why duplexing is always turning on everytime you open a
word document.

No, I created a brand new template and saved it to a folder on a server. I
then attached the template to the document I want to be duplexed.
 
J

Jonathan West

The problem is that the setting applies to the printer, not to the document.
So the printer is set to duplex when you open the document, and remains so
for all documents until you close the document.

The code in my article sets the duplex just prior to printing and then
resets it immediately after, leaving the printing of other documents
unaffected. This is how you need to proceed.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 

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