+ Reply to Thread
Results 1 to 4 of 4

How to assign an object to a child IE window

  1. #1
    Jason
    Guest

    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. #2
    Tim Williams
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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. #3
    Jason
    Guest

    Re: 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" <[email protected]> wrote in message
    > news:[email protected]...
    > > 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!

    >
    >
    >


  4. #4
    Registered User
    Join Date
    01-27-2014
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: How to assign an object to a child IE window

    Hi Jason,
    Can you please be more specific that how did you get to the solution or can you please share the code?
    Iam facing the same problem and need urgent solution. Iam stuck at the new child window being generated and not able to control that new child window!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1