Link to home
Start Free TrialLog in
Avatar of kwitcom
kwitcomFlag for United States of America

asked on

VBScript in ASP to print page. Need help making it print more copies.

I need to make this code print 2 copies and also make it print 4 copies.

label.asp

<script language="VBScript">
SUB Print()
    OLECMDID_PRINT = 6
    OLECMDEXECOPT_DONTPROMPTUSER = 2
    OLECMDEXECOPT_PROMPTUSER = 1
    'Bring focus to the document so that it will be what prints:
    document.body.focus()
    'Call the "Print" command. Since the Internet Explorer/DOM didn't add
    'the "print()" method until 5.0
    on error resume next
    call IEWB.ExecWB (OLECMDID_PRINT, -1)
    if err.number <> 0 then
        alert "Nothing Printed"
    end if
    location.replace("index.asp")
END SUB

</script>
<body onload="print()">
<object id="IEWB" width="0" height="0" classid="clsid:8856F961-340A-11D0-A96B-00C04FD705A2">
          </object>
ASKER CERTIFIED SOLUTION
Avatar of alorentz
alorentz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kwitcom

ASKER

Ok had to make a small change but got it.  Thnx

<script language="VBScript">
SUB Print()
    OLECMDID_PRINT = 6
    OLECMDEXECOPT_DONTPROMPTUSER = 2
    OLECMDEXECOPT_PROMPTUSER = 1
    'Bring focus to the document so that it will be what prints:
    document.body.focus()
    'Call the "Print" command. Since the Internet Explorer/DOM didn't add
    'the "print()" method until 5.0
    on error resume next
 for i = 1 to 4
    call IEWB.ExecWB (OLECMDID_PRINT, -1)
 next
    if err.number <> 0 then
        alert "Nothing Printed"
    end if
    location.replace("index.asp")
END SUB

</script>
<body onload="print()">
<object id="IEWB" width="0" height="0" classid="clsid:8856F961-340A-11D0-A96B-00C04FD705A2">
          </object>