Open new IE Window from VB Script 
Author Message
 Open new IE Window from VB Script

Hello,

I'm just learning VB Scripting, so please bear with me.  I have found in the
VB Script FAQ how to change the contents of a frame in a web page, or the
page as a whole using:

parent.location.href = webaddress

Now how do I open a new IE window from VB Script??

The relevant section of my script is:

<SCRIPT LANGUAGE="VBScript">
<!--
Option Explicit
On Error Resume Next

Dim WSHShell, MyBox,  t, vers
Dim update1, update2, update3, update4, urladdr

Set WSHShell = WScript.CreateObject("WScript.Shell")
update1 = "Upgrading to version 5.1 of VB Script and version" & vbCR
update2 = "2.0 of Windows Scripting Host are recommended." & vbCR
update3 = "Would you like to go to the download page now?"
update4 = update1 & update2 & update3
urladdr = " http://www.*-*-*.com/ ;

'Check WSH Version. If earlier than 5.1 display dialog and ask if
'user wants to go to Scripting Page.
vers = WScript.Version
t = "WSH Version check"
If vers < 5.1 Then
 MyBox = MsgBox(update4 , 4161, t)
 If MyBox = vbCancel Then
     WScript.Quit
 ElseIf MyBox = vbOK Then
     parent.location.href = urladdr
     WScript.Quit
 End If
End If
-->
</SCRIPT>

Thanks,

Doug Knox



Mon, 20 May 2002 03:00:00 GMT  
 Open new IE Window from VB Script
In addition to the problem of opening the URL in a new window, the line:

vers = WScript.Version

Does not return a value I can test for.  It works fine as a stand alone
script.  What am I missing?

Thanks,

Doug


Quote:
> Hello,

> I'm just learning VB Scripting, so please bear with me.  I have found in
the
> VB Script FAQ how to change the contents of a frame in a web page, or the
> page as a whole using:

> parent.location.href = webaddress

> Now how do I open a new IE window from VB Script??

> The relevant section of my script is:

> <SCRIPT LANGUAGE="VBScript">
> <!--
> Option Explicit
> On Error Resume Next

> Dim WSHShell, MyBox,  t, vers
> Dim update1, update2, update3, update4, urladdr

> Set WSHShell = WScript.CreateObject("WScript.Shell")
> update1 = "Upgrading to version 5.1 of VB Script and version" & vbCR
> update2 = "2.0 of Windows Scripting Host are recommended." & vbCR
> update3 = "Would you like to go to the download page now?"
> update4 = update1 & update2 & update3
> urladdr = "http://msdn.microsoft.com/scripting"

> 'Check WSH Version. If earlier than 5.1 display dialog and ask if
> 'user wants to go to Scripting Page.
> vers = WScript.Version
> t = "WSH Version check"
> If vers < 5.1 Then
>  MyBox = MsgBox(update4 , 4161, t)
>  If MyBox = vbCancel Then
>      WScript.Quit
>  ElseIf MyBox = vbOK Then
>      parent.location.href = urladdr
>      WScript.Quit
>  End If
> End If
> -->
> </SCRIPT>

> Thanks,

> Doug Knox



Mon, 20 May 2002 03:00:00 GMT  
 Open new IE Window from VB Script

1) To open the page in a new window:

window.open "webaddress"

or if you want an object reference to the new window (assuming the page is in the same domain);

set newwin = window.open("webaddress")

2) You can't refer to WScript.Version in an html page (WScript isn't the host), but you can check the VBScript version:

vers = ScriptEngineMajorVersion & "." & ScriptEngineMinorVersion
if CSng(vers) < 5.1 then
    ...

3) Nor can you do WScript.Quit.

The blanket use of On Error Resume Next hides all of the errors that result from references to WScript.

--
Michael Harris


  In addition to the problem of opening the URL in a new window, the line:

  vers = WScript.Version

  Does not return a value I can test for.  It works fine as a stand alone
  script.  What am I missing?

  Thanks,

  Doug



  > Hello,
  >
  > I'm just learning VB Scripting, so please bear with me.  I have found in
  the
  > VB Script FAQ how to change the contents of a frame in a web page, or the
  > page as a whole using:
  >
  > parent.location.href = webaddress
  >
  > Now how do I open a new IE window from VB Script??
  >
  > The relevant section of my script is:
  >
  > <SCRIPT LANGUAGE="VBScript">
  > <!--
  > Option Explicit
  > On Error Resume Next
  >
  > Dim WSHShell, MyBox,  t, vers
  > Dim update1, update2, update3, update4, urladdr
  >
  > Set WSHShell = WScript.CreateObject("WScript.Shell")
  > update1 = "Upgrading to version 5.1 of VB Script and version" & vbCR
  > update2 = "2.0 of Windows Scripting Host are recommended." & vbCR
  > update3 = "Would you like to go to the download page now?"
  > update4 = update1 & update2 & update3
  > urladdr = "http://msdn.microsoft.com/scripting"
  >
  > 'Check WSH Version. If earlier than 5.1 display dialog and ask if
  > 'user wants to go to Scripting Page.
  > vers = WScript.Version
  > t = "WSH Version check"
  > If vers < 5.1 Then
  >  MyBox = MsgBox(update4 , 4161, t)
  >  If MyBox = vbCancel Then
  >      WScript.Quit
  >  ElseIf MyBox = vbOK Then
  >      parent.location.href = urladdr
  >      WScript.Quit
  >  End If
  > End If
  > -->
  > </SCRIPT>
  >
  > Thanks,
  >
  > Doug Knox
  >
  >



Mon, 20 May 2002 03:00:00 GMT  
 Open new IE Window from VB Script
Michael,

Your assistance is GREATLY appreciated!   Thanks!

Doug

--
Visit this part of my home page for some helpful
Cosmetic, Security and Utility Tweaks for Win98.
http://members.xoom.com/dbknox/registry/index.htm
New Tweaks and Files added often.


1) To open the page in a new window:

window.open "webaddress"

or if you want an object reference to the new window (assuming the page is
in the same domain);

set newwin = window.open("webaddress")

2) You can't refer to WScript.Version in an html page (WScript isn't the
host), but you can check the VBScript version:

vers = ScriptEngineMajorVersion & "." & ScriptEngineMinorVersion
if CSng(vers) < 5.1 then
    ...

3) Nor can you do WScript.Quit.

The blanket use of On Error Resume Next hides all of the errors that result
from references to WScript.

--
Michael Harris



  In addition to the problem of opening the URL in a new window, the line:

  vers = WScript.Version

  Does not return a value I can test for.  It works fine as a stand alone
  script.  What am I missing?

  Thanks,

  Doug



  > Hello,
  >
  > I'm just learning VB Scripting, so please bear with me.  I have found in
  the
  > VB Script FAQ how to change the contents of a frame in a web page, or
the
  > page as a whole using:
  >
  > parent.location.href = webaddress
  >
  > Now how do I open a new IE window from VB Script??
  >
  > The relevant section of my script is:
  >
  > <SCRIPT LANGUAGE="VBScript">
  > <!--
  > Option Explicit
  > On Error Resume Next
  >
  > Dim WSHShell, MyBox,  t, vers
  > Dim update1, update2, update3, update4, urladdr
  >
  > Set WSHShell = WScript.CreateObject("WScript.Shell")
  > update1 = "Upgrading to version 5.1 of VB Script and version" & vbCR
  > update2 = "2.0 of Windows Scripting Host are recommended." & vbCR
  > update3 = "Would you like to go to the download page now?"
  > update4 = update1 & update2 & update3
  > urladdr = "http://msdn.microsoft.com/scripting"
  >
  > 'Check WSH Version. If earlier than 5.1 display dialog and ask if
  > 'user wants to go to Scripting Page.
  > vers = WScript.Version
  > t = "WSH Version check"
  > If vers < 5.1 Then
  >  MyBox = MsgBox(update4 , 4161, t)
  >  If MyBox = vbCancel Then
  >      WScript.Quit
  >  ElseIf MyBox = vbOK Then
  >      parent.location.href = urladdr
  >      WScript.Quit
  >  End If
  > End If
  > -->
  > </SCRIPT>
  >
  > Thanks,
  >
  > Doug Knox
  >
  >



Mon, 20 May 2002 03:00:00 GMT  
 Open new IE Window from VB Script
Doug, this is the routine I have been using to check for WSH 2 in local .vbs
file:

Set ws = WScript.CreateObject("WScript.Shell")

'Check for WSH 2.0 + needed for SendKeys and AppActivate.
If WScript.Version < 5.1 Then
  q = ws.Popup ("You need Windows Script 5.1 or " & _
    "higher to run this script.  Do you want to down" & _
    "load it now?",,"Invalid Script Version Error",52)
  If q = 7 Then WScript.Quit 'User selected no at prompt.
  MsgBox "Run script again after download " & _
    "and install is completed."
  ws.Run "http://www.microsoft.com/msdownload/" & _
    "vbscript/scripting.asp"
  WScript.Quit
End If

This will open the default browser on the system.  Depending on settings, if
the browser is already open it will use that instance, though.

Bill James


Quote:
> Michael,

> Your assistance is GREATLY appreciated!   Thanks!

> Doug

> --
> Visit this part of my home page for some helpful
> Cosmetic, Security and Utility Tweaks for Win98.
> http://members.xoom.com/dbknox/registry/index.htm
> New Tweaks and Files added often.



> 1) To open the page in a new window:

> window.open "webaddress"

> or if you want an object reference to the new window (assuming the page is
> in the same domain);

> set newwin = window.open("webaddress")

> 2) You can't refer to WScript.Version in an html page (WScript isn't the
> host), but you can check the VBScript version:

> vers = ScriptEngineMajorVersion & "." & ScriptEngineMinorVersion
> if CSng(vers) < 5.1 then
>     ...

> 3) Nor can you do WScript.Quit.

> The blanket use of On Error Resume Next hides all of the errors that
result
> from references to WScript.

> --
> Michael Harris



>   In addition to the problem of opening the URL in a new window, the line:

>   vers = WScript.Version

>   Does not return a value I can test for.  It works fine as a stand alone
>   script.  What am I missing?

>   Thanks,

>   Doug



>   > Hello,

>   > I'm just learning VB Scripting, so please bear with me.  I have found
in
>   the
>   > VB Script FAQ how to change the contents of a frame in a web page, or
> the
>   > page as a whole using:

>   > parent.location.href = webaddress

>   > Now how do I open a new IE window from VB Script??

>   > The relevant section of my script is:

>   > <SCRIPT LANGUAGE="VBScript">
>   > <!--
>   > Option Explicit
>   > On Error Resume Next

>   > Dim WSHShell, MyBox,  t, vers
>   > Dim update1, update2, update3, update4, urladdr

>   > Set WSHShell = WScript.CreateObject("WScript.Shell")
>   > update1 = "Upgrading to version 5.1 of VB Script and version" & vbCR
>   > update2 = "2.0 of Windows Scripting Host are recommended." & vbCR
>   > update3 = "Would you like to go to the download page now?"
>   > update4 = update1 & update2 & update3
>   > urladdr = "http://msdn.microsoft.com/scripting"

>   > 'Check WSH Version. If earlier than 5.1 display dialog and ask if
>   > 'user wants to go to Scripting Page.
>   > vers = WScript.Version
>   > t = "WSH Version check"
>   > If vers < 5.1 Then
>   >  MyBox = MsgBox(update4 , 4161, t)
>   >  If MyBox = vbCancel Then
>   >      WScript.Quit
>   >  ElseIf MyBox = vbOK Then
>   >      parent.location.href = urladdr
>   >      WScript.Quit
>   >  End If
>   > End If
>   > -->
>   > </SCRIPT>

>   > Thanks,

>   > Doug Knox



Mon, 20 May 2002 03:00:00 GMT  
 Open new IE Window from VB Script
Bill,

See Michael Harris' earlier post on this subject.   I had the version
checking working in VBS files, but could not make it work in an actual HTML
script.  According to Michael, you can't check WScript functions from a web
page (most likely a security feature).  His example worked fine.  You can
see it at my web site below.  The script is embedded into the bottom frame.

Regards,
Doug Knox
--
Visit this part of my home page for some helpful
Cosmetic, Security and Utility Tweaks for Win98.
http://members.xoom.com/dbknox/registry/index.htm
New Tweaks and Files added often.


Quote:
> Doug, this is the routine I have been using to check for WSH 2 in local
.vbs
> file:

> Set ws = WScript.CreateObject("WScript.Shell")

> 'Check for WSH 2.0 + needed for SendKeys and AppActivate.
> If WScript.Version < 5.1 Then
>   q = ws.Popup ("You need Windows Script 5.1 or " & _
>     "higher to run this script.  Do you want to down" & _
>     "load it now?",,"Invalid Script Version Error",52)
>   If q = 7 Then WScript.Quit 'User selected no at prompt.
>   MsgBox "Run script again after download " & _
>     "and install is completed."
>   ws.Run "http://www.microsoft.com/msdownload/" & _
>     "vbscript/scripting.asp"
>   WScript.Quit
> End If

> This will open the default browser on the system.  Depending on settings,
if
> the browser is already open it will use that instance, though.

> Bill James



> > Michael,

> > Your assistance is GREATLY appreciated!   Thanks!

> > Doug

> > --
> > Visit this part of my home page for some helpful
> > Cosmetic, Security and Utility Tweaks for Win98.
> > http://members.xoom.com/dbknox/registry/index.htm
> > New Tweaks and Files added often.



> > 1) To open the page in a new window:

> > window.open "webaddress"

> > or if you want an object reference to the new window (assuming the page
is
> > in the same domain);

> > set newwin = window.open("webaddress")

> > 2) You can't refer to WScript.Version in an html page (WScript isn't the
> > host), but you can check the VBScript version:

> > vers = ScriptEngineMajorVersion & "." & ScriptEngineMinorVersion
> > if CSng(vers) < 5.1 then
> >     ...

> > 3) Nor can you do WScript.Quit.

> > The blanket use of On Error Resume Next hides all of the errors that
> result
> > from references to WScript.

> > --
> > Michael Harris



> >   In addition to the problem of opening the URL in a new window, the
line:

> >   vers = WScript.Version

> >   Does not return a value I can test for.  It works fine as a stand
alone
> >   script.  What am I missing?

> >   Thanks,

> >   Doug



> >   > Hello,

> >   > I'm just learning VB Scripting, so please bear with me.  I have
found
> in
> >   the
> >   > VB Script FAQ how to change the contents of a frame in a web page,
or
> > the
> >   > page as a whole using:

> >   > parent.location.href = webaddress

> >   > Now how do I open a new IE window from VB Script??

> >   > The relevant section of my script is:

> >   > <SCRIPT LANGUAGE="VBScript">
> >   > <!--
> >   > Option Explicit
> >   > On Error Resume Next

> >   > Dim WSHShell, MyBox,  t, vers
> >   > Dim update1, update2, update3, update4, urladdr

> >   > Set WSHShell = WScript.CreateObject("WScript.Shell")
> >   > update1 = "Upgrading to version 5.1 of VB Script and version" & vbCR
> >   > update2 = "2.0 of Windows Scripting Host are recommended." & vbCR
> >   > update3 = "Would you like to go to the download page now?"
> >   > update4 = update1 & update2 & update3
> >   > urladdr = "http://msdn.microsoft.com/scripting"

> >   > 'Check WSH Version. If earlier than 5.1 display dialog and ask if
> >   > 'user wants to go to Scripting Page.
> >   > vers = WScript.Version
> >   > t = "WSH Version check"
> >   > If vers < 5.1 Then
> >   >  MyBox = MsgBox(update4 , 4161, t)
> >   >  If MyBox = vbCancel Then
> >   >      WScript.Quit
> >   >  ElseIf MyBox = vbOK Then
> >   >      parent.location.href = urladdr
> >   >      WScript.Quit
> >   >  End If
> >   > End If
> >   > -->
> >   > </SCRIPT>

> >   > Thanks,

> >   > Doug Knox



Tue, 21 May 2002 03:00:00 GMT  
 Open new IE Window from VB Script

[...]you can't check WScript functions from a web
page (most likely a security feature). [...]

It's _not_ security...  The "built-in" WScript object is only exposed to script code when WScript.exe or CScript.exe is the host for the script engine.  In an HTML page, IExplore.exe is the host.

--
Michael Harris



Tue, 21 May 2002 03:00:00 GMT  
 Open new IE Window from VB Script
Hello,

I'm just learning VB Scripting, so please bear with me.  I have found in
the
VB Script FAQ how to change the contents of a frame in a web page, or
the
page as a whole using:

parent.location.href = webaddress

Now how do I open a new IE window from VB Script??

The relevant section of my script is:

<SCRIPT LANGUAGE="VBScript">
<!--
Option Explicit
On Error Resume Next

Dim WSHShell, MyBox,  t, vers
Dim update1, update2, update3, update4, urladdr

Set WSHShell = WScript.CreateObject("WScript.Shell")
update1 = "Upgrading to version 5.1 of VB Script and version" & vbCR
update2 = "2.0 of Windows Scripting Host are recommended." & vbCR
update3 = "Would you like to go to the download page now?"
update4 = update1 & update2 & update3
urladdr = "http://msdn.microsoft.com/scripting"

'Check WSH Version. If earlier than 5.1 display dialog and ask if
'user wants to go to Scripting Page.
vers = WScript.Version
t = "WSH Version check"
If vers < 5.1 Then
 MyBox = MsgBox(update4 , 4161, t)
 If MyBox = vbCancel Then
     WScript.Quit
 ElseIf MyBox = vbOK Then
     parent.location.href = urladdr
     WScript.Quit
 End If
End If
-->
</SCRIPT>

Thanks,

Doug Knox



Tue, 21 May 2002 03:00:00 GMT  
 Open new IE Window from VB Script
instead of

 update1 = "Upgrading to version 5.1 of VB Script and version" & vbCR
 update2 = "2.0 of Windows Scripting Host are recommended." & vbCR
 update3 = "Would you like to go to the download page now?"
 update4 = update1 & update2 & update3
 urladdr = "http://msdn.microsoft.com/scripting"

why not just have 1 variable ot save memory by using

update1 = "Upgrading to version 5.1 of VB Script and version" & vbCR
update1 = update1 & "2.0 of Windows Scripting Host are recommended." & vbCR
 etc...

and change the 1 part of your message box since there will only be 1 update
variable

  MyBox = MsgBox(update1 , 4161, t)

trippz



Wed, 22 May 2002 03:00:00 GMT  
 Open new IE Window from VB Script
Trippz,

Thanks for the tip.  This isn't going to be a very intensive script, but I
guess every little bit of memory helps.  I used to do BASIC programming back
on the C-64 (yep good old Commodore), but wasn't sure if that particular
method would work in VB script and hadn't even gotten around to trying it
yet.  Was busier trying to get the d**n thing to work in the first place!

Regards,
Doug
--
Visit this part of my home page for some helpful
Cosmetic, Security and Utility Tweaks for Win98.
http://members.xoom.com/dbknox/registry/index.htm
New Tweaks and Files added often.


Quote:
> instead of

>  update1 = "Upgrading to version 5.1 of VB Script and version" & vbCR
>  update2 = "2.0 of Windows Scripting Host are recommended." & vbCR
>  update3 = "Would you like to go to the download page now?"
>  update4 = update1 & update2 & update3
>  urladdr = "http://msdn.microsoft.com/scripting"

> why not just have 1 variable ot save memory by using

> update1 = "Upgrading to version 5.1 of VB Script and version" & vbCR
> update1 = update1 & "2.0 of Windows Scripting Host are recommended." &
vbCR
>  etc...

> and change the 1 part of your message box since there will only be 1
update
> variable

>   MyBox = MsgBox(update1 , 4161, t)

> trippz



Wed, 22 May 2002 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. IE Open frame in new window in VB

2. Opening new IE window?

3. VB6:Open new IE window from EXISTING process

4. Opening links in new IE window

5. Open new IE window

6. Completely Preventing IE from opening on a New Window Request

7. How to open Netscape / IE in new window

8. Submitting form opens new window in IE

9. how do I open the current window again without opening a new window

10. Opening a new IE window a set size

11. open a new IE window?

12. onClick to open selection in new Window - NS 4 works, IE 4 Fails

 

 
Powered by phpBB® Forum Software