Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634

    Unanswered: changing printer

    I need to create pdf files then print the pdf files to specific printers.
    Environment: Access 2010, Windows 7, Adobe Acrobat 9 Pro

    I start out with the printerA as the system default. I use SetDefaultPrinter to change to printerB. Then create and print the pdfs using DoCmd.OutputTo and ShellExecute(print). This is working correctly.

    I then use SetDefaultPrinter to change the printer back to printerA and go throught the above steps to create and print the pdfs that should print on printerA. This is where the issue is. The printer changes (devices and printers now shows printerA as the default and ? printer.devicename in the immediate window returns printerA), but the pdf file prints to printerB. If I manually open a pdf file and change the printer to printerA, subsequint pdfs will then print to printerA.

    Any thoughts or suggestions would be appreciated.

  2. #2
    Join Date
    Nov 2011
    Posts
    413
    Open the report in design view.
    Choose Page Setup from the File menu.
    On the middle tab, choose Specific Printer.
    Ok the dialog, and save the report.
    It will now remember to go to that specific printer.

    If you are developing for others, so you don't know ahead of time what
    printer they will want to use for a report, see:
    Printer Selection Utility
    at:
    Printer Selection Utility

  3. #3
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634
    Thanks for the response.

    I need to do this through code. I'm looping through a record set and need the report to print to different printers (in different physical locations) based on a field in the record. I'm trying to avoid setting up (and maintaining) multiple versions of the report.

    It's looking like I'll end up opening and the first pdf for each location and changing the printer. It's not pretty, but it'll get the job done.

  4. #4
    Join Date
    Nov 2011
    Posts
    413
    Then use If ([field name]) = " something" Then
    Set Printer
    DoCmd.OpenReport "your report"
    Else
    use default printer

    Did you read the information in the link I sent? Seems to me it provides a solution with the addition of a simple If statement.

    Good Luck,

  5. #5
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634
    Here's what I'm doing within the loop for each location.

    Open Records for a specific location
    SetDefaultPrinter for that location

    for each record in that location
    create pdf and save using Docmd.OutputTo
    pint pdf using ShellExecute
    email the pdf

    move to next record

    I'm not printing the report directly from access, I'm printing the pdf - for legal reasons it has narrow margins that some printers readjust and the hard copy must exactly match the electronic copy. Changing Application.Printer has no effect.

    The first change works perfectly. The issue is with subsequent changes. When I change the system printer using SetDefaultPrinter the change can be seen in both the immediate window (? printer.devicename) and in the windows Printers and Devices dialog, but the pdfs continue to be sent to the first printer.

  6. #6
    Join Date
    Nov 2011
    Posts
    413
    I only have one printer so I can't really test this.Are you using Cutepdf or another program as your printer? Are your printer needs changing for each physical location? Does printer depend on criteria? Maybe someone else with more experience can help with this. I have suggested all I know to do.

    Best of Luck!

Posting Permissions

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