Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to assign an object to a child IE window
Hi,
I am trying to automate a web form-filling process, and when the form is submitted a child window of IE pops up with the results...I am having a lot of trouble assigning a new object to this new instance of IE (so that I can further manipulate this in my VBA code). Could someone please detail the code required to do this? So far I have: --------------------- Sub AutoIE() Dim IE1 As InternetExplorer Dim IE2 As InternetExplorer Set IE1 = New InternetExplorer ' Do my stuff with IE1 and submit the form '.... ' New child window pops up here '< Need your help here on how to set IE2 to the new child window (with IE1 still ' open/running) End Sub --------------------- Any help or suggestions would be greatly appreciated! Many thanks for your time in advance! :) |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to assign an object to a child IE window
See "GetIE" below - it will search for an open IE window which has a URL beginning with the string parameter "sLocation". You'll just need to fing the URL of the pop-up window (try Ctrl-N...) Tim. Sub test2() Dim o Set o = GetIE("http://www.yahoo.com") If Not o Is Nothing Then MsgBox o.document.body.innerHTML Else MsgBox "No Yahoo page found" End If End Sub Function GetIE(sLocation As String) As Object Dim objShell As Object, objShellWindows As Object, o As Object Dim sURL As String Dim retVal As Object Set retVal = Nothing Set objShell = CreateObject("Shell.Application") Set objShellWindows = objShell.Windows For Each o In objShellWindows sURL = "" On Error Resume Next 'check the URL and if it's the one you want then ' assign it to the return value sURL = o.document.Location On Error GoTo 0 If sURL Like sLocation & "*" Then Set retVal = o Exit For End If Next o Set GetIE = retVal End Function "Jason" wrote in message ... Hi, I am trying to automate a web form-filling process, and when the form is submitted a child window of IE pops up with the results...I am having a lot of trouble assigning a new object to this new instance of IE (so that I can further manipulate this in my VBA code). Could someone please detail the code required to do this? So far I have: --------------------- Sub AutoIE() Dim IE1 As InternetExplorer Dim IE2 As InternetExplorer Set IE1 = New InternetExplorer ' Do my stuff with IE1 and submit the form '.... ' New child window pops up here '< Need your help here on how to set IE2 to the new child window (with IE1 still ' open/running) End Sub --------------------- Any help or suggestions would be greatly appreciated! Many thanks for your time in advance! :) |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to assign an object to a child IE window
Hi Tim,
Thanks! It works like a charm- you're a lifesaver!! :) Jason. "Tim Williams" wrote: See "GetIE" below - it will search for an open IE window which has a URL beginning with the string parameter "sLocation". You'll just need to fing the URL of the pop-up window (try Ctrl-N...) Tim. Sub test2() Dim o Set o = GetIE("http://www.yahoo.com") If Not o Is Nothing Then MsgBox o.document.body.innerHTML Else MsgBox "No Yahoo page found" End If End Sub Function GetIE(sLocation As String) As Object Dim objShell As Object, objShellWindows As Object, o As Object Dim sURL As String Dim retVal As Object Set retVal = Nothing Set objShell = CreateObject("Shell.Application") Set objShellWindows = objShell.Windows For Each o In objShellWindows sURL = "" On Error Resume Next 'check the URL and if it's the one you want then ' assign it to the return value sURL = o.document.Location On Error GoTo 0 If sURL Like sLocation & "*" Then Set retVal = o Exit For End If Next o Set GetIE = retVal End Function "Jason" wrote in message ... Hi, I am trying to automate a web form-filling process, and when the form is submitted a child window of IE pops up with the results...I am having a lot of trouble assigning a new object to this new instance of IE (so that I can further manipulate this in my VBA code). Could someone please detail the code required to do this? So far I have: --------------------- Sub AutoIE() Dim IE1 As InternetExplorer Dim IE2 As InternetExplorer Set IE1 = New InternetExplorer ' Do my stuff with IE1 and submit the form '.... ' New child window pops up here '< Need your help here on how to set IE2 to the new child window (with IE1 still ' open/running) End Sub --------------------- Any help or suggestions would be greatly appreciated! Many thanks for your time in advance! :) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
assign keystroke to object or button | Excel Worksheet Functions | |||
FileSearch Object - Cannot assign to variable | Excel Programming | |||
Can't assign a textbox to object | Excel Programming | |||
Can't assign a textbox to object | Excel Programming | |||
assign the sub to the object event | Excel Programming |