Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2007

Tip: Looking for answers? Try searching our database.

VBA Duplexing won't reset

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sasquatch - 10 Apr 2007 17:18 GMT
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...
GeorgeW - 10 Apr 2007 18:30 GMT
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...

> I'm back again :(
>
[quoted text clipped - 67 lines]
>
> Thanks in advance...
Sasquatch - 10 Apr 2007 22:02 GMT
> 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.
Jonathan West - 16 Apr 2007 13:14 GMT
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.

Signature

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

> I'm back again :(
>
[quoted text clipped - 75 lines]
>
> Thanks in advance...
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.