Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 367
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 367
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
assign keystroke to object or button rufusf Excel Worksheet Functions 0 March 6th 06 09:35 AM
FileSearch Object - Cannot assign to variable Alan Excel Programming 1 January 24th 05 03:41 AM
Can't assign a textbox to object colin.. Excel Programming 4 December 9th 04 03:35 AM
Can't assign a textbox to object colin.. Excel Programming 0 December 8th 04 06:41 PM
assign the sub to the object event Marek Excel Programming 1 September 13th 04 08:50 PM


All times are GMT +1. The time now is 10:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"