Print without prompting

Batch, ASP, JScript, Kixtart, etc.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 13 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
lilsizzo
Posts: 2
Last visit: Thu Aug 19, 2010 3:59 pm

Print without prompting

Post by lilsizzo »

Hi there, is there any possibility to make this vbscript acceptable in hta? It is currently workin in IE but not HTA.<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>
User avatar
lilsizzo
Posts: 2
Last visit: Thu Aug 19, 2010 3:59 pm

Print without prompting

Post by lilsizzo »

Hi there, is there any possibility to make this vbscript acceptable in hta? It is currently workin in IE but not HTA.<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>
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Print without prompting

Post by jvierra »

Put the following in a file with an hta EXTENSION.

Code: Select all

<input type="button" value="Print Me" onclick='print()'/>
When all good men come to the aid of their party ... and party dood! 
When all good men come to the aid of their party ... and party dood!
jvierra2010-08-19 23:37:31
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Print without prompting

Post by jvierra »

YOu cannot do that.

I posted code for you to test. Just put it in an HTA with nothing wlse to see how it works.

YOu are, for some unknown reason, trying to add you old non-functionaly code to the correct code posted.

This goes in a file with an HTA extension

Code: Select all

<input type="button" value="Print Me" onclick='print()'/>
Hello World will print now!

Nothing else. Just those two lines.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Print without prompting

Post by jvierra »

Here is the documentation for the 'print' method of WIndows.

http://msdn.microsoft.com/en-us/library ... S.85).aspx

The object you are trying to use will not work in IE or in an HTA. The object has been disabled for security reasons.

The code I posted is the minimum code needed to demonstrate the function.

Note that ny file, even an empty file will run as an hta if you give it an HTA extension.

Try creating an empty HTA file and running it. Use the "View Source" menu item to look at teh file. You will be surprised by what seems to be in a file that is empty.

This can be usefule if you forget the structure of an HTML file as you can copy and paste this and it will have been created by WIndows. Sort of auto file generation.

COntents of an empty file.

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
<HTML><HEAD> 
<META content="text/html; charset=windows-1252" http-equiv=Content-Type></HEAD> 
<BODY></BODY></HTML>

This is because the browser is required by HTML rules to provide default base items for a page.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Print without prompting

Post by jvierra »

THe object will not run in an HTA.

jvierra2010-08-20 06:16:38
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Print without prompting

Post by jvierra »

That's right. You can't do hidden printing. It hasn't been available for years even if there are Internet posts to the contrary.
jvierra2010-08-24 03:22:57
This topic is 13 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked