Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 388
  • Last Modified:

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>
0
kwitcom
Asked:
kwitcom
1 Solution
 
alorentzCommented:
Could try:

<script language="VBScript">
SUB Print(howmany)
    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 howmany
    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>
0
 
kwitcomAuthor Commented:
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>
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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