To print Webbrowser control use any of these three options.
1. Sending ^p key, using SendKeys, which is not really clean programming
2. Using the shell command, and rundll32
Shell "rundll32.exe C:\WINDOWS\SYSTEM\MSHTML.DLL,PrintHTML " & _ "http://www.yahoo.com" , vbMinimizedFocus
3. Finally, method 3, this will be a best method, and uses the built-in commands for the web-browser.
Private Sub PrintHtmlPage()
'first navigate to the HTML Page
'if you want to print current HTML no need to navigate
WebBrowser1.Navigate ("http://www.developerfusion.com/")
DoEvents
'print
WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER
'you can change OLECMDEXECOPT_DONTPROMPTUSER to OLECMDEXECOPT_PROMPTUSER if you wish
End Sub
1. Sending ^p key, using SendKeys, which is not really clean programming
2. Using the shell command, and rundll32
Shell "rundll32.exe C:\WINDOWS\SYSTEM\MSHTML.DLL,PrintHTML " & _ "http://www.yahoo.com" , vbMinimizedFocus
3. Finally, method 3, this will be a best method, and uses the built-in commands for the web-browser.
Private Sub PrintHtmlPage()
'first navigate to the HTML Page
'if you want to print current HTML no need to navigate
WebBrowser1.Navigate ("http://www.developerfusion.com/")
DoEvents
WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER
'you can change OLECMDEXECOPT_DONTPROMPTUSER to OLECMDEXECOPT_PROMPTUSER if you wish
End Sub
浙公网安备 33010602011771号