Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[?] Print with IE on vbs program

17 views
Skip to first unread message

Pennywise

unread,
Mar 12, 2004, 5:20:39 AM3/12/04
to
Can anyone help me to print an html file with IE 6 with an vbs script

--
Pennywise
Questo messaggio è composto al 100% da
elettroni riciclati. Nessun atomo è stato
ionizzato per trasmettere questo messaggio.

McKirahan

unread,
Mar 12, 2004, 10:09:08 AM3/12/04
to
"Pennywise" <pennyw...@ccvvdd.it> wrote in message
news:Xns94AA745B4B055...@127.0.0.1...

Are you looking for something like:

Option Explicit
Const cVBS = "IE~Print.vbs"
Dim objIEA
Dim strMSG
Dim strURL
strURL = "http://www.Google.com/"
strURL = InputBox("Enter a URL: ",cVBS,strURL)
If strURL <> vbCancel Then
Set objIEA = CreateObject("InternetExplorer.Application")
objIEA.Visible = True
objIEA.Navigate strURL
strMSG = MsgBox("Print this page?",vbOKCancel+vbQuestion,cVBS)
If strMSG = vbOK Then
While objIEA.Busy
Wend
objIEA.ExecWB 6, 2
End If
Set objIEA = Nothing
End If


TDM

unread,
Mar 12, 2004, 10:31:35 AM3/12/04
to

This may not be what you want, requires user intervention, but
it may be a start.

Dim objIE
Dim objIEDoc

Set objIE = WScript.CreateObject("InternetExplorer.Application")

With objIE
.Navigate("http://www.microsoft.com")
.Visible = True
Do While .Busy
WScript.Sleep 100
Loop
Set objIEDoc = .Document

With objIEDoc
If .queryCommandSupported("Print") Then .execCommand "Print", True
End With

End With

TDM

"Pennywise" <pennyw...@ccvvdd.it> wrote in message
news:Xns94AA745B4B055...@127.0.0.1...

> Can anyone help me to print an html file with IE 6 with an vbs script
>
> --
> Pennywise

> Questo messaggio č composto al 100% da
> elettroni riciclati. Nessun atomo č stato

Pennywise

unread,
Mar 15, 2004, 3:57:50 AM3/15/04
to
Thanks!! It's Great... but an other question... how I can setup the page
properties before printing?? I need to setup landscape orientation and the
top/bottom margines

Thanks!

McKirahan

unread,
Mar 15, 2004, 8:18:33 AM3/15/04
to
"Pennywise" <pennyw...@ccvvdd.it> wrote in message
news:Xns94AD647BA8109...@127.0.0.1...

www.meadroid.com/scriptx/

Absolute control over document printing operations from client and server
computers running Microsoft's Internet Explorer browser.

Support for all versions of Internet Explorer from IE 4.01 SP1 to IE 6.0 SP1
on Microsoft operating systems from Windows 95 to Windows XP.


DX398

unread,
Mar 20, 2004, 12:10:31 PM3/20/04
to
On Fri, 12 Mar 2004 15:09:08 GMT, "McKirahan" <Ne...@McKirahan.com>
wrote:

> strURL = InputBox("Enter a URL: ",cVBS,strURL)
>If strURL <> vbCancel Then

Just curious... why are you checking against vbCancel here?

According to the documentation:

"...If the user clicks Cancel, the function returns a zero-length
string ("")."

DX

Torgeir Bakken (MVP)

unread,
Mar 20, 2004, 12:33:51 PM3/20/04
to
DX398 wrote:

Hi

Actually, it returns it as type Empty (but you can test on it
with "" and get a hit as well).

Running this script and pressing Cancel:

'--------------------8<----------------------
strURL = "http://something"
cVBS = "something"


strURL = InputBox("Enter a URL: ",cVBS,strURL)

WScript.Echo "TypeName is: " & TypeName(strURL)

If strURL = vbCancel Then
WScript.Echo "Hit on vbCancel"
End If

if IsEmpty(strURL) Then
WScript.Echo "Hit on IsEmpty"
End If

if strURL = "" Then
WScript.Echo "Hit on zero-length string"
End If
'--------------------8<----------------------


will get you this output:

TypeName is: Empty
Hit on IsEmpty
Hit on zero-length string


So you are correct, testing on vbCancel is meaningless.


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/community/scriptcenter/default.mspx

Joe Earnest

unread,
Mar 20, 2004, 3:13:16 PM3/20/04
to
Hi Torgeir,

"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message
news:uoOedGq...@TK2MSFTNGP11.phx.gbl...

You could, however, test with False (the function, not vbFalse) -- it seems
to be coerced to a string if not empty, and the dialog return seems to be
coerced to a boolean if empty, so that:

(strURL=false) gives
boolean True, if cancelled (cancel, Esc, x, close)
boolean False, if Ok clicked
(for either "" or "...", even if "False" is entered)

Curious, huh? ;-)
Seems to be an effect of the "tri-state" string return.

Regards,
Joe Earnest

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.564 / Virus Database: 356 - Release Date: 01-19-04


McKirahan

unread,
Mar 21, 2004, 2:13:38 PM3/21/04
to
"DX398" <dx...@ziplip.com> wrote in message
news:8luo50d4sj3haccd1...@4ax.com...

If strURL <> vbCancel Then
Set objIEA = CreateObject("InternetExplorer.Application")

If the user presses Cancel then I don't want to open up an instance of IE.


DX398

unread,
Mar 21, 2004, 3:40:15 PM3/21/04
to
On Sun, 21 Mar 2004 19:13:38 GMT, "McKirahan" <Ne...@McKirahan.com>
wrote:

> If strURL <> vbCancel Then
> Set objIEA = CreateObject("InternetExplorer.Application")
>
>If the user presses Cancel then I don't want to open up an instance of IE.

I understand that.

But my point is: shouldn't this be checking against the empty string
instead?

If strURL <> "" Then ...

DX

McKirahan

unread,
Mar 21, 2004, 5:40:06 PM3/21/04
to
"DX398" <dx...@ziplip.com> wrote in message
news:5bvr50hu6rtsb9ncr...@4ax.com...

You're right:
If strURL <> vbCancel Then
should be
If strURL <> "" Then

I was thinking of the test for MsgBox as in:

Dim strBOX
strBOX = MsgBox("?",vbQuestion+vbOkCancel,"")
If strBOX = vbOK Then MsgBox("OK")
If strBOX = vbCancel Then MsgBox("Cancel")


0 new messages