My goal is to print a web page from a C# application without the printer selection dialog box popping up (this is a kiosk application). To do this, I'm injecting the following script into the HTML stream:
<script language='VBScript'>
Sub Print()
OLECMDID_PRINT = 6
OLECMDEXECOPT_DONTPROMPTUSER = 2
OLECMDEXECOPT_PROMPTUSER = 1
call WB.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER,1)
End Sub
document.write "<object ID='WB' WIDTH=0 HEIGHT=0 CLASSID='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'></object>"</script><script>window.print();</script>The page seems to load fine, but I'm getting the error "Object doesn't support this property or method: "WB.ExecWB", see the attached screen shot below. I'm using .Net 4.5 on Windows 7. Is there any way I can make this work?