IE Automation and Frames

mugginsjr

New Member
Joined
Nov 29, 2011
Messages
40
I am attempting to automate a form on our business proprietary website - which has nested frames. There are a few select drop-down elements and a few text box elements on the frame. I have searched the internet and tried just about everything but keep failing to snag the sub frames needed to fill out the form. I'm hoping someone with experience can take a moment to direct me.

There is another non-secure website built on the exact same frameset as our proprietary page that I can direct you too. This is the info I can so far assess:

Site: http://webcache.gmc-uk.org/gmclrmp_enu/start.swe
(I found this while searching for excel help on the frame name "_sweclient")
(The designer must have used the same software to create this page that my outfit used.)

Frame Hierarchy: "_sweclient" --> wasn't able to get far enough to find any more sub frames - but it used to be "_sweview"

Text Box element Name = 's_3_1_6_0'
Text Box element ID = "surname"

Whenever I try to snag the frame document it returns the top document. I had a working version a couple of years ago but they have updated the site and now I am hitting a brick wall.

Below is my code thus far. (I need to connect to an already open instance of IE because we can not hard-code password and ID information. The site must be logged into and already at the page with the form before snagging it.)

Code:
Sub getOpenIEbyTitleORurl()
'***************************************************************
'   This subroutine grabs an already open instance of IE
'   and assigns it as an internet Explorer object in order
'   to fill out a form on the page by automation

'   TEST WEB PAGE = http://webcache.gmc-uk.org/gmclrmp_enu/start.swe
'
'   Text Box name =  's_3_1_6_0'      Textbox id = "surname"
'***************************************************************

Dim Boolean_indicator As Boolean
Dim current_title As String
Dim current_url As String
Dim HTMLdoc As HTMLDocument
Dim IE As InternetExplorer
Dim objIterator As Object
Dim frameColl As FramesCollection

    Boolean_indicator = False
    Set objIterator = CreateObject("Shell.Application")

    For x = 0 To objIterator.Windows.Count
        On Error Resume Next
        current_title = objIterator.Windows(x).Document.Title
        current_url = objIterator.Windows(x).******************

        If InStr(1, current_title, "Doctor Search") > 0 Then 'is this my webpage?
            Set IE = objIterator.Windows(x)
            Boolean_indicator = True
            Exit For
        End If
    Next

    If Boolean_indicator = False Then
        MsgBox ("Your webpage is not open")
    Else
        MsgBox ("Your webpage is open...")
        IE.Visible = True
    End If

'***************************************************************
'   The following section manipulates a frameset in order to
'   control the form - which is on a sub-frame
'   _sweclient --> _sweview --> ???
'***************************************************************

'   FIRST ATTEMPT
    Set HTMLdoc = IE.Document
    Set second_level_Frame = HTMLdoc.getElementsByName("_sweclient")(0)
    Set third_level_Frame = HTMLdoc.frames(0)
    Debug.Print second_level_Frame.Document.body.innerhtml

'   SECOND ATTEMPT
    '    Set HTMLdoc = theFrame.contentWindow.Document
    'set third_level_Frame =
    'Set second_level_Frame = IE.Document.frames("_sweclient")
'    Debug.Print second_level_Frame.Document.body.innerhtml


'   THIRD ATTEMPT
'    Set frameColl = IE.Document.frames
'     For Each frm In frameColl
'        abc = frm.Name
'           If frm.Name = "_sweclient" Then
'                 Set HTMLdoc = frm.Document
'                 Exit For
'           End If
'
'     Next frm

'   FOURTH ATTEMPT
'    Set acctInput = IE.Document.getElementById("surname")
'    acctInput.Focus
'    acctInput.Value = "12345"




Set HTMLdoc = Nothing
Set IE = Nothing
End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Try:
Code:
    Dim IE As InternetExplorer
    Dim HTMLdoc As HTMLDocument
    Dim frame As HTMLWindow2
    Dim surnameInput As HTMLInputElement

    Set HTMLdoc = IE.document
    Set frame = HTMLdoc.frames("_sweclient")
    Set HTMLdoc = frame.document
    Set frame = HTMLdoc.frames("_sweview")
    Set HTMLdoc = frame.document
    Set surnameInput = HTMLdoc.getElementById("surname")
which gets you to the form input elements.
 
Upvote 0
Try:
Code:
    Dim IE As InternetExplorer
    Dim HTMLdoc As HTMLDocument
    Dim frame As HTMLWindow2
    Dim surnameInput As HTMLInputElement

    Set HTMLdoc = IE.document
    Set frame = HTMLdoc.frames("_sweclient")
    Set HTMLdoc = frame.document
    Set frame = HTMLdoc.frames("_sweview")
    Set HTMLdoc = frame.document
    Set surnameInput = HTMLdoc.getElementById("surname")
which gets you to the form input elements.

Works like a charm! Thank you so much John.
 
Upvote 0
Cross-posted: Automate IE11 - Form in nested frame won't work

Please post links to all your posts for this question on all other forums where you've posted this question. Why? Please read Excelguru Help Site - A message to forum cross posters.


I apologize for my ignorance on that John. I posted this question on another forum, Automate IE11 - Form in nested frame won't work, for the same answer a couple of days prior to this one. I didn't realize the full ramifications of that. I certainly appreciate the efforts of any one who volunteers their time and effort to help others - and I certainly hope to be able to help others as well.... Thanks for pointing that out.
 
Upvote 0

Forum statistics

Threads
1,213,520
Messages
6,114,099
Members
448,548
Latest member
harryls

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