Is it possible to control the IE browser print dialog box in VBA without using SendKeys?
Asked
Active
Viewed 997 times
-3
-
Please read https://stackoverflow.com/help/how-to-ask on how to ask a good question on SO. – silentsurfer Aug 30 '17 at 15:04
-
Thanks for the link. I'm new, now I'll get acquainted with the rules. – footballplayer Aug 30 '17 at 15:09
1 Answers
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