Topic: Printing from VBScript
Share/Save/Bookmark
Printing From VBScript allows you to bypass the Print Dialog box
 
1. You must add the following object in the <head> tags of the markup language
<object id="ParentWBControl" width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>
 
2. Add the following JavaScript to the <Body> tag or put in .js file
      <script language="JavaScript" type="text/javascript">
      <!--
      function doPrint()
      {
        if(window.print)
        {
            if (navigator.appName.indexOf('Microsoft') != -1)
            {
              VBPrint();
            }
            else
            {
              self.print();
            }
        }
      }
      //-->
      </script>
 
3. Add the following VBScript in the <Body> tag below the JavaScript above
      <script language="VBScript" type="text/vbscript"><!--
          Sub VBPrint()
              ParentWBControl.ExecWB 6,2 //second parameter (1 = show print dialog, 2 = no show)
          End sub//-->
      </script>