• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1046
  • Last Modified:

convert javascript to vbscript code

I have a function in javascript. Does the following:
1) Print the webpage
2) toggle visibility for a couple of table elements
3) print another copy
4) trigger a button click (so I can execute soem code in the code behind VB.NET

I needed a silen print (print from IE9 without print prompt for printer selection)

So I replaced step 1 with the following vbscript. Now I need help to convert the steps 2,3,4 from javascript to vbscript.. Please help. Thanks.

VBscript:
<script language='VBScript' type="text/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>

Javascript:

<script type="text/javascript">
    function Print() {
       window.print();
       

       var tblStore = document.getElementById("<%= tblDash.ClientID %>");
       tblStore.style.display = 'none';

       var tblCustomer = document.getElementById("<%= tblCustomerCopy.ClientID %>");
       tblCustomer.style.display = 'block';
       window.print();

       var clickButton = document.getElementById("<%= lnkHome.ClientID %>");
        clickButton.click();
    }
    </script>
0
TrialUser
Asked:
TrialUser
1 Solution
 
JonNormanCommented:
From vbscript you can call javascript, so you could do something like the following:
<script language='VBScript' type="text/vbscript">
Sub Print()
       OLECMDID_PRINT = 6
       OLECMDEXECOPT_DONTPROMPTUSER = 2
       OLECMDEXECOPT_PROMPTUSER = 1
       call WB.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER,1)
       doAfterFirstPrint()
       call WB.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER,1)
       doClickButton()
End Sub
document.write "<object ID='WB' WIDTH=0 HEIGHT=0 CLASSID='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'></object>"
</script>

Javascript:

<script type="text/javascript">
    function Print() {
       window.print();
       doAfterFirstPrint();
       window.print();
       doClickButton();
    }
    function doAfterFirstPrint() {
       var tblStore = document.getElementById("<%= tblDash.ClientID %>");
       tblStore.style.display = 'none';

       var tblCustomer = document.getElementById("<%= tblCustomerCopy.ClientID %>");
       tblCustomer.style.display = 'block';
    }
    function doClickButton() {
       var clickButton = document.getElementById("<%= lnkHome.ClientID %>");
        clickButton.click();
    }
    </script>

Open in new window

0
 
TrialUserAuthor Commented:
awesome, exactly what i wanted. Thanks a bunch
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now