-3

Is it possible to control the IE browser print dialog box in VBA without using SendKeys?

1 Answers1

0

It is, by using the InternetExplorer object's ExecWB method (see this link for details).

After adding a reference to the Microsoft Internet Controls library to your project, the following example should get you started:

Option Explicit

Sub PrintWebPage()

    Dim ie As InternetExplorer

    Set ie = New InternetExplorer

    ie.Navigate "http://www.google.com/"
    ie.Visible = 1

    'Wait for page to finish loading
    Do While ie.ReadyState <> READYSTATE_COMPLETE
     DoEvents
    Loop

    ie.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER

    MsgBox "Done printing.", vbInformation

End Sub
silentsurfer
  • 1,998
  • 2
  • 17
  • 29
  • Thanks for the answer! That's what I need! Tell me please, is it possible to check whether the IE browser print dialog box is already open with the help of the OLECMDID_PRINT command? For example, can I check whether the user opened the browser's print dialog box? – footballplayer Aug 30 '17 at 15:07