none
print from Internet Explorer and force specified printer to be used RRS feed

  • Question

  • From Access 2010 and/or 2016, I can connect to IE and print the page displayed in the browser:

    Dim ie As InternetExplorerMedium  
    ie.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER  

    But I can't figure out how to specify the "Adobe PDF" printer that I want to use.

    Anyone know how to do this?

    I don't want to change the Windows default printer, and I don't think changing the Access.Application.Printer has any effect. I just want to change the one IE print command to go to a specific printer.

    If there's a good way to do it, I would then also restore the printer to what it was after I've printed my one web page.

    Thursday, February 1, 2018 5:30 PM

Answers

  • The only work around I found to this issue is to change windows default printer using this command

    Shell "RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n "PrinterName"

    The downside to this solution is that if the program crashes before it changes the printer back to original printer, then the user settings got changed and have to be manually changed back in the control panel

    Thursday, May 24, 2018 12:38 PM

All replies

  • Hi GordonPrince4575,

    From your description, It looks like issue is more related with IE instead of MS Access.

    So for better response and better solution for your issue, I move this thread to IE Development forum.

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.

    Thank you for your understanding.

    Regards,

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, February 2, 2018 6:36 AM
    Moderator
  • Hi,

    OLECMD_PRINT uses your DEFAULT printer....

    Regards.


    Rob^_^

    Sunday, February 4, 2018 11:47 PM
  • Actually, my testing shows it doesn't use the default printer. It uses the last printer used by IE.

    When IE starts it defaults to the default printer. But if you leave IE open and change the Windows default printer, IE continues to use the printer that was the default when IE launched. Or the last printer used by an IE print job. There doesn't seem to be a way to force IE to use a specific printer from VBA the way one can from Access or Excel.
    Monday, February 5, 2018 11:34 AM
  • Hi GordonPrince4575,

    I suggest you could firstly change the  change your default printer in windows and check the value of Application.ActivePrinter to get the exact name of the printer that you want to use.

    The codes:

    Sub SwitchPrinter()
        Dim prt As Printer
        ' Get current default printer
        Set prt = Application.Printer
        ' Set default printer
        Application.Printer = Application.Printers("OtherPrinter")
        ' Print something, e.g.
        DoCmd.PrintOut
        ' Restore original printer
        Set Application.Printer = prt
    End Sub
    list the names of available printers
    Sub ListPrinters()
        Dim prt As Printer
        For Each prt In Printers
            Debug.Print prt.DeviceName
        Next prt
    End Sub

    Best Regards,

    Brando


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, February 7, 2018 5:16 AM
  • From Access VBA, wouldn't "application.printer =" set the Access application's printer? I'm trying to set IE's printer, and that's what there doesn't seem to be a way to do.

        Application.Printer = Application.Printers("Adobe PDF")

    doesn't change the printer the IE uses.

        Set prt = ie.Application.Printer

    throws an error: "Object doesn't support this property or method."

    Am I missing something that should work here?

    Wednesday, February 7, 2018 8:22 PM
  • The only work around I found to this issue is to change windows default printer using this command

    Shell "RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n "PrinterName"

    The downside to this solution is that if the program crashes before it changes the printer back to original printer, then the user settings got changed and have to be manually changed back in the control panel

    Thursday, May 24, 2018 12:38 PM