Internet Explorer Object | Pop up Window

gduron

Board Regular
Joined
Mar 27, 2006
Messages
94
Hello,

I have a VBA project that navigates to a website and then clicks on a link. When I click the link in my code a new IE Browser opens with a form that I wan to fill out. I know how to update the form, but I don't know how to reference the new browser window that was opened when I clicked on the link.

Here is some of my code:

Code:
'Open End User Multiple Selection
Set tags = myIE.document.getElementsByTagName("A")
For Each tag In tags
    If InStr(1, tag, "'multiple_selections.htm','EndUser'", vbTextCompare) > 0 Then
        tag.Click
        Exit For
    End If
Next

when I try to reference the document in the popup window, it is still referencing the previous window. How can I set my "myIE" object to reference the new pop up window?

Thanks in advance for your help.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Re: Internet Explorer Object | Pop up Window Control - Solution

Ok, well thanks to some diligent searching on the internet, I found a solution to the problem. If you are ever using Excel VBA to click on a link and it opens a pop-up window, your internet explorer object will continue to reference the parent browser and not the child browser. I found this code on another site to help you create an object that will allow you to manipulate the child or pop-up browser:

Code:
Dim objSW As ShellWindows
Dim objIE As InternetExplorer

Set objSW = New ShellWindows
For Each x In objSW
        If x.LocationName = "Multiple Selection" Then
            Set objIE = x
            Exit For
        End If
Next x

The ojSW will contain all of the open windows on your computer (as objects of course). You can iterate through each one of them until you find the "LocationName" of the window that you are interested in. Once you find it, set your new IE variable equal to that object and you can keep playing with it.

Thanks for your help.


Hello,

I'm using this old post as a guide, just hope that someone can give the extra hand I need to finish my task.

I'm using this code to control a pop up (also named child) IE window that appears after opening a webpage. The "child" window (called Internet Explorer) asks the user what to do with the file requested: Open, Save or Save As, using the code from this post I'm able to take control of the child (or that's what I believe, I haven't found a way to prove it), but now how can I find the variable or property in that child screen that controls what to do with the file?

Below the code I have so far:

Code:
Sub FollowLink()

'Activate references
'Microsoft HTML Object Library
'Microsoft Internet Controls

Dim ie As InternetExplorer
Dim objIE As InternetExplorer
Dim objSW As ShellWindows
Dim html As HTMLDocument
Dim Link As Object
Dim ElementCol As Object

Set ie = New InternetExplorer
ie.Visible = True


ie.navigate Cells(7, 2) '"https://yahoo.com" for instance...

'Wait for the child to load
     
Application.Wait (Now + TimeValue("00.00.10"))

'This is the code from this post

Set objSW = New ShellWindows
For Each x In objSW
        If x.LocationName = "Internet Explorer" Then
            Set objIE = x
            Exit For
        End If
Next x

'This generates error 91: Object variable  or With block variable not set
MsgBox "Internet Explorer window found:" & vbCrLf &
              "LocationURL=" & objIE.LocationURL & vbCrLf & _
              "LocationName=" & objIE.LocationName

End Sub

Thanks in advance for your help.
 
Upvote 0
Re: Internet Explorer Object | Pop up Window Control - Solution

The "child" window (called Internet Explorer) asks the user what to do with the file requested: Open, Save or Save As, using the code from this post I'm able to take control of the child (or that's what I believe, I haven't found a way to prove it), but now how can I find the variable or property in that child screen that controls what to do with the file?
Is it an IE window or a Windows file download window? If that latter, use Windows API functions to click the required button and, if needed, populate the download file name field.. The calls required depend on the version of IE.

For IE8 - http://www.mrexcel.com/forum/excel-...ile-download-dialog-box-without-sendkeys.html

For IE9+ - VBA/VB.Net/VB6

Alternatively, you could use UIAutomationClient - set a reference to this in the VBA project.
 
Upvote 0
Re: Internet Explorer Object | Pop up Window Control - Solution

John,

Both, first an IE window, then a file download window.

Thanks, I'll take notes on your suggestion!

Pegaso
 
Upvote 0

Forum statistics

Threads
1,214,377
Messages
6,119,182
Members
448,872
Latest member
lcaw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top