--
Pennywise
Questo messaggio è composto al 100% da
elettroni riciclati. Nessun atomo è stato
ionizzato per trasmettere questo messaggio.
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
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
Thanks!
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.
> 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
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
"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
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.
> 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
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")