Handle pop-up windows in internet explorer

evdokimos

Board Regular
Joined
Mar 10, 2003
Messages
72
Hi all
I have the following macro that opens a site then click on a button to customize search. When it is executed, a new window is opened to tick some boxes. I want to tick all boxes but I don’t know how to do it programmatically. I search similar cases but I couldn't find an answer. Any ideas?

Sub OpenSite()
Set IE = New InternetExplorer
Set objHTML = New HTMLDocument
apiShowWindow IE.hwnd, SW_MAXIMIZE
URL = "http://www.ebay.co.uk/sch/i.html?_nkw=art&_in_kw=1&_ex_kw=&_sacat=0&_udlo=&_udhi=&_ftrt=901&_ftrv=1&_sabdlo=&_sabdhi=&_samilow=&_samihi=&_sargn=-1%26saslc%3D1&_salic=3&_sop=12&_dmd=1&_ipg=50"
With IE
.navigate URL
.Visible = True
While .Busy Or .readyState <> READYSTATE_COMPLETE
DoEvents
Wend
Set objHTML = .document
DoEvents
End With
Set ButtonIE = IE.document.getElementById("custLink")
ButtonIE.Click
End Sub
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
You first need to reference the new IE window, using one of the following methods:

1. Loop through Shell.Windows looking for the IE window with some attribute which matches the one you're looking for, e.g. IE. LocationURL, IE.LocationName, IE.Document.Title, etc.

2. Loop through SHDocVw.ShellWindows (SHDocVw is the library which contains the InternetExplorer class), looking for the IE window with some attribute which matches the one you're looking for, e.g. IE. LocationURL, IE.LocationName, IE.Document.Title, etc.

3. Use a class module with Public WithEvents IE As InternetExplorer, and trap the NewWindow2 event.

Once you have an object reference to the new IE window, you can reference the HTMLDocument element within it, and tick the boxes, which are probably HTMLInputElement elements.
 
Upvote 0

Forum statistics

Threads
1,216,780
Messages
6,132,669
Members
449,745
Latest member
victoriar

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