How to use VBScript in IE to print directly without prompting
This article will explain in detail how to use VBScript in IE to print directly without prompting. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
First, add the Object of WebBrowser to the HTML page:
After that, print with the following code:
Sub printvb ()
Wb.execwb 6,2,3
End Sub
The key code wb.execwb 6jing2jing3 can actually print directly without prompting in VBScript mode, but it is strange that with the same parameters, IE will still pop up a print conversation window in Javascript mode, perhaps because VBScript is developed by Microsoft specifically for IE, while Javascript is an outsider after all:)
Another more comprehensive example can be found as follows:
6=OLECMDID_PRINT
2=OLECMDEXECOPT_DONTPROMPTUSER
2+1=PRINT_WAITFORCOMPLETION + PRINT_DONTBOTHERUSER
WB.ExecWB 6, 2, 3, 0
Sub window_onunload
On Error Resume Next
Set WB = nothing
End Sub
Sub vbPrintPage (x, y, z)
OLECMDID_PRINT = 6
OLECMDEXECOPT_DODEFAULT = 0
OLECMDEXECOPT_PROMPTUSER = 1
OLECMDEXECOPT_DONTPROMPTUSER = 2
On Error Resume Next
WB.ExecWB x, y, z, 0
End Sub
Print Test
This is the end of this article on "how to print directly without prompting in VBScript in IE". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.