+ Reply to Thread
Results 1 to 13 of 13

Print Duplex

  1. #1
    Registered User
    Join Date
    05-11-2010
    Location
    A far away land
    MS-Off Ver
    Excel 2003
    Posts
    38

    Question Print Duplex

    I am running two macros to print selections of a sheet. They are both included below. Can I add a setting somewhere in the macro to make them print duplex.

    1st

    Please Login or Register  to view this content.
    2nd

    Please Login or Register  to view this content.
    I am running both macros at the same time in a seperate macro and calling on both macros I just didnt know if it was possible or where it would go.

    Thanks

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Print Duplex

    Hello Redeoclown,

    Unfortunately VBA did not add a Printer Object as Visual Basic did. If Microsoft had then this would wouldn't be so difficult. Actually, I have done the difficult part for you. Copy all of this code into a separate VBA module. This is what is needed to set a printer to duplex or back to simplex mode.
    Please Login or Register  to view this content.

    Example for Setting the ActivePrinter to Duplex (Book style)
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    01-25-2011
    Location
    Virginia
    MS-Off Ver
    Excel 2016
    Posts
    166

    Re: Print Duplex

    Leith,
    I have serched all over the internet and you seem to be the only one that has addressed this issue. However after applying your code I cannot get the printer to switch to duplex or back (it stays in whatever mode it was in before I run the code). The code runs without error and I tried all three duplex settings (1-3) but no go? I am running Windows 7 and Excel 2010 - any suggestions on what it might be or trouble shooting I could do?

    Thanks,

    Tom

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Print Duplex

    Hello Tom,

    I will check on what the cause might be or ways we can troubleshoot it. The API has evolved some since Windows XP. The biggest change is with 64 bit Windows. However, if you were using Windows 64 the code would have failed to run.

    What printer are you using this on?

  5. #5
    Forum Contributor
    Join Date
    01-25-2011
    Location
    Virginia
    MS-Off Ver
    Excel 2016
    Posts
    166

    Re: Print Duplex

    Leith,

    Thanks for the quick reply. The printer is an HP 2605DN, about 4 yrs old.

    Tom
    Last edited by tom.hogan; 01-24-2012 at 11:00 PM.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Print Duplex

    Hello Tom,

    Thanks for the printer info. Is this a personal printer or a networked printer?

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Print Duplex

    Hello Tom,

    No need to answer the last post. The printer specs indicate it uses HP PLC (Printer Control Language) 6. It most likely is not responding to API command because it expects a PLC command to set the duplex option. I will work on some code to send the PLC command to printer. That should work for you.

  8. #8
    Forum Contributor
    Join Date
    01-25-2011
    Location
    Virginia
    MS-Off Ver
    Excel 2016
    Posts
    166

    Re: Print Duplex

    Leith,

    I am currently using the PCL driver but it has as a postscript driver that I could use if that would make it easier.

    Tom

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Print Duplex

    Hello Tom,

    Try this macro. It should send the set duplex command directly to the printer in PCL.
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    01-25-2011
    Location
    Virginia
    MS-Off Ver
    Excel 2016
    Posts
    166

    Re: Print Duplex

    Leith,
    Thanks for all the help. I have tried your macro and it runs without error. It does duplex (I can see the page go through the duplexer) but it prints a blank page. I tried setting a print range with ActiviateSheet.PageSetup.PrintArea but that did not help. I also tried changing the CMD= to SimplexMode but it still duplexes a blank sheet. I did step through the macro and the value for CMD is changing based on the CMD = line but it still duplexes. I also tried setting CMD to DuplexLegal but got the same result.

    Clearly some cmd is being sent to the printer, but it needs a little tweeking? Also, I relooked my print driver and it is PS not PCL. HP does not have a PCL driver for Windows 7.

    Regards,

    Tom

  11. #11
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Print Duplex

    Hello Tom,

    I will have to check on the Post Script method for setting the printer to duplex mode. At least we are making headway.

  12. #12
    Forum Contributor
    Join Date
    01-25-2011
    Location
    Virginia
    MS-Off Ver
    Excel 2016
    Posts
    166

    Re: Print Duplex

    Leith,
    I give up. I got so frustrated I went out an bought a new printer, HP CP2025dn. I did a bunch of internet research and your API code looks perfect. I also confirmed that the PCL code is correct. So i installed the new printer wiht PCL driver and tried both of your codes (plus a simular API code form MSFT site) and none of them work. I can only guess that it has something to do with the fact that I am printing to it as a network printer (static IP) but I don't understand why that would matter.

    Thanks again for your help, this may be one of those problems for which there is not a VBA solution.

    Regards,

    Tom

  13. #13
    Forum Contributor
    Join Date
    01-25-2011
    Location
    Virginia
    MS-Off Ver
    Excel 2016
    Posts
    166

    Re: Print Duplex

    Leith,
    The plot thickens. I read else where that if you changed the printer back and forth then the duplex setting would take. This did not work for me unitl i did it twice in a row. So with your code and the below macro I can now change my printer's duplex setting:
    Please Login or Register  to view this content.
    I irritates me that I don't understand why this works, but it does so I guess it's solved. I can't mark this as solved but I have rated you highly thanks for the help.

    Tom

    P.S. If you can explain why this works I would like to hear it!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1