• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 14971
  • Last Modified:

How do I activate (bring to front) an internet explorer window in VBScript?

Hi, I have a VBscript that opens up 3 windows in IE, and it resizes them so they tile in a certain arrangement on my screen. I want to know how I can activate (or bring to the front) one of the windows so I can send text to it. Attached is my code. Thanks!
 
 
 
On Error Resume Next
 
Set objShell = CreateObject("Shell.Application")
Set objShellWindows = objShell.Windows
Set IE1 = objShellWindows.Item
Set IE2 = objShellWindows.Item
Set IE3 = objShellWindows.Item
 
URL1 = "http://zip4.usps.com/zip4/welcome.jsp"
URL2 = "http://maps.google.com/"
URL3 = "http://fedexifc.infousa.com/QAA/demo/Login.aspx"
 
IE3.Navigate2 URL3
If err.number <> 0 Then
 Set IE3 = wscript.CreateObject("internetexplorer.application")
 
 InfoUSALogin(IE3)
 
End If
 
IE1.Navigate2 URL1
If err.number <> 0 Then
 Do While IE3.Busy
 Loop
 Set IE1 = wscript.CreateObject("internetexplorer.application")
 IE1.Visible = True
 IE1.Navigate2 URL1
 IE1.Height = 525
 IE1.Width = 642
 IE1.Left = 0
 IE1.Top = 0
End If
 
 
 
IE2.Navigate2 URL2
If err.number <> 0 Then
 Set IE2 = wscript.CreateObject("internetexplorer.application")
 IE2.Visible = True
 IE2.Navigate2 URL2
 IE2.Height = 1050
 IE2.Width = 642
 IE2.Left = 642
 IE2.Top = 0
End If
 
 
Set IE1 = Nothing
Set IE2 = Nothing
Set IE3 = Nothing
Set objShellWindows = Nothing
Set objShell = Nothing
 
 
 
Private Sub InfoUSALogin(ie)
Dim wshShell
 
Set wshShell = WScript.CreateObject("WScript.Shell")
 
ie.Visible = True
ie.Navigate2("http://fedexifc.infousa.com/QAA/demo/Login.aspx")
 
Do while ie.Busy
Loop
 
wshShell.SendKeys "username"
wshShell.SendKeys "{TAB}"
wshShell.SendKeys "password"
wshShell.SendKeys "{TAB}"
wshShell.SendKeys "group"
wshShell.SendKeys "{TAB}"
wshShell.SendKeys "{ENTER}"
 
ie.Height = 525
ie.Width = 642
ie.Left = 0
ie.Top = 500
 
End Sub

Open in new window

0
jssutton11
Asked:
jssutton11
  • 2
1 Solution
 
sirbountyCommented:
Try using the wscript.shell method of AppActivate...

Example:

Set objWShell = CreateObject("Wscript.Shell") 
Set objShell = CreateObject("Shell.Application")
Set objShellWindows = objShell.Windows
Set IE1 = objShellWindows.Item
URL = "http://maps.google.com/"
IE1.Navigate2 URL
wscript.sleep 5000
objWShell.appactivate ("Google Maps") 'Title of the window...

Open in new window

0
 
Michel PlungjanIT ExpertCommented:
does

ie.Focus

or

ie.Focus()
work?
0
 
jssutton11Author Commented:
Thank you for the solution!
0
 
sirbountyCommented:
Happy to help - thanx for the grade! :^)
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

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