PDA

View Full Version : control internet explorer popup window from excel



rbradshaw
12-13-2011, 12:24 PM
Hi,

I am stuck and after some help...

I have written a macro which opens internet explorer, fills in the relevant fields then submits the form. occasionally a popup window will appear asking for confirmation which i want to focus on and click the confirm button and then carry on inputting data onto the original internet explorer window. i have been told to use a withevent but i cannot get it to work.

this is what i have so far:

this is the code in class1

Public WithEvents IeWe As InternetExplorer Private Sub IeWe_NewWindow2(ppDisp As Object) Dim PopupWin As InternetExplorer Set PopupWin = ppDisp 'code to click button .... End Sub


this is the code in a module

Dim newopenwin As New Class1 Public Sub gogogo() Dim ie As InternetExplorer Dim objCollection As Object Dim objCollection2 As Object ... Set objCollection = ie.document.getElementsByTagName("td") j = 0 while j < objCollection.Length If objCollection(j).ID = "addLinkSum" Then Set objCollection2 = objCollection(j).getElementsByTagName("a") k = 0 While k < objCollection2.Length If objCollection2(k).innerText = "Add" And added = 0 Then 'when link is clicked popup window appears objCollection2(k).Click End If k = k + 1 Wend End If j = j + 1 Wend ...


can anybody please help??

thanks :)

Bob Phillips
12-13-2011, 03:36 PM
Cross-posted at Xtreme VBTalk http://www.xtremevbtalk.com/showthread.php?t=322935