Print HTML Using IE
I’ve might have mentioned before that I am not well versed in Visual Basic. Here is a small Visual Basic script snippet that took me an afternoon to figure out. You can use this code to print an HTML file using Internet Explorer. After the HTML file has been printed Internet Explorer will close.
Sub PrintHtml(fileName) Dim objIE Set objIE = WScript.CreateObject( _ "InternetExplorer.Application", "ie_") objIE.Visible = True objIE.Navigate filename do until objIE.readystate = 4 : wscript.sleep 20 : loop print_done=false ' 6 = PRINT, 2 = NO USER PROMPT objIE.ExecWB 6, 2 ' Wait until printing id done. do while not print_done : wscript.sleep 50 : loop objIE.Quit End Sub ' Listen to ie print events sub ie_PrintTemplateTeardown(pDisp) wscript.sleep 200 print_done=true end sub