Results 1 to 6 of 6
  1. #1
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930

    Set Printer Duplexing

    I have VBA code to set printer to duplex print a report if the user's default printer is a particular brand. This code worked for years under Windows XP and Access 2007. Several months ago upgraded everyone to Windows 7 and Access 2010 and the code no longer works. Weirdness is one user is sure this worked for him just last week and db records support that - regardless, it isn't working for anyone to any printer now. More weirdness - code to select printer bin still works. Also, the duplexing constants are still recognized by VBA. I have debugged and confirm the code executes. I have tried printer power off/on.

    The code is simply:

    If strPrinter Like "*Konica*" Then Reports(strReport).Printer.Duplex = acPRDPHorizontal
    ...
    If strPrinter Like "*Konica*" Then Reports(strReport).Printer.Duplex = acPRDPSimplex

    Before I try Windows API code from http://support.microsoft.com/kb/230743, wondering if anyone else has had similar experience and found a simpler solution.

    My research indicates this is an issue across the MS Office Suite starting with 2010. However, this thread indicates to me that my code should still work http://answers.microsoft.com/en-us/o...7-4e65b4f09645.

    This is the only issue I have encountered with the upgrades and really sucks!
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I usually go after the driver and have not tried anything fancy with 2010 yet. Maybe this will help though.

    Not sure if you can change these designs during Run Time.
    If the printer driver supports it you can use the Printers object and the Duplex property.
    http://msdn.microsoft.com/en-us/libr...ffice.14).aspx

    You can set the form.Printer or report.printer property. Not sure what the constant for use duplex is. You could probably set the form's properties to duplex and then see what integer it returns.
    http://msdn.microsoft.com/en-us/libr...ffice.14).aspx

    You can iterate available printers to dynamically assign default printers to the Application. Maybe this is where your problem lies.
    https://www.accessforums.net/program...tml#post222315
    Last edited by ItsMe; 05-21-2014 at 05:41 PM. Reason: said "report" changed to application

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I was not able to get "Printer.Duplex = acPRDPHorizontal" to work on two different brand workstation printers. I tried XP with Access 2003 and W7 Access 2010. I tried forms, reports, opening forms with acViewDesign and acFormEdit, etc. No problem switching default printers back and forth using Application.Printer but could not change printer settings to duplex using the Printer object.

    I was able to get the function you linked to to work on both printers using the XP machine. The newer Lexmark printer would not work on the W7 and I did not bother installing the Brother on W7 to test the Brother printer. The Lexmark uses the winspool driver so I am not sure why W7 is not allowing the function to work. Access is 32 bit and I believe that the Kernal32.dll is available.

    EDIT: I was able to get the function to work on the W7 machine too. However, all I am able to do is change the printer properties. Meaning, the report still does not care and the report's page setup properties are overriding the printer properties. I double checked on the XP machine and it is the same there too. The report's page setup properties are overriding any other properties set via code or the OS' Printers and Faxes window.
    Last edited by ItsMe; 05-22-2014 at 06:09 AM.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Thanks for all that effort ItsMe. Some of it sounds like what I experienced when I first explored code to manage duplexing before I finally got the posted code to work 4 years ago.

    I was just about to try the API code but sounds like that will be futile. I think I will have to change code to prompt user to flip the page and re-feed it regardless of the printer capabilities. It's only one report now since I managed to reconfigure others to a single page.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I looked at some old code and it looks like what I did in the past was use the Page Properties of the report. So if need be, create two report objects. The only thing about that is your development machine needs to have that specific printer and drivers installed. So if IT comes in and installs a replacement printer, same brand and model, it could SNAFU. One thing I try to do is keep Device Name and Port Name the same. During install of new equipment I will use the same Device Name and Port Name based on the physical location of the printer. Nice in theory but sometimes impractical.

    Anyway, post if anything new develops. EDIT and yah the UDF is great but the Report object does not care what the Printer settings are via the OS's Printer Window thing. I tried all sorts of combinations.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    After some discussion in office, determined only one user has to generate this report. That user has a duplexing Konica. In fact, staff changes really mean only this one person is now outputting any of these reports. So am setting this one report for printing to specific printer, not default printer, and setting it for duplex.

    Thank you ItsMe, problem solved, once I figure out which flip option works.

    Still SUCKS that the code failed with software 'upgrades'.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Using a thremal printer for labels
    By kcmiuser in forum Reports
    Replies: 3
    Last Post: 03-24-2014, 01:49 PM
  2. Printer Selection in VBA code
    By trevor40 in forum Reports
    Replies: 2
    Last Post: 03-08-2014, 03:31 PM
  3. Replies: 3
    Last Post: 02-25-2014, 11:46 AM
  4. Print to Default Printer
    By bsc0617 in forum Access
    Replies: 7
    Last Post: 10-10-2013, 07:46 AM
  5. Forms to Printer
    By Roland in forum Reports
    Replies: 1
    Last Post: 11-22-2010, 10:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums