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

Posted on 2009-02-13
Last Modified: 2012-05-06
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 = ""

URL2 = ""

URL3 = ""


IE3.Navigate2 URL3

If err.number <> 0 Then

 Set IE3 = wscript.CreateObject("internetexplorer.application")


End If


IE1.Navigate2 URL1

If err.number <> 0 Then

 Do While IE3.Busy


 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



Do while ie.Busy



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

Question by:jssutton11
    LVL 67

    Accepted Solution

    Try using the method of AppActivate...

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

    Open in new window

    LVL 75

    Expert Comment

    by:Michel Plungjan




    Author Closing Comment

    Thank you for the solution!
    LVL 67

    Expert Comment

    Happy to help - thanx for the grade! :^)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Title # Comments Views Activity
    count7 challenge 12 52
    object oriented javascript web form 8 48
    nestparen challenge 4 33
    wordcount challenge 11 46
    I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
    Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now