Get Frame Collection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pod
    Contributor
    • Sep 2007
    • 298

    #1

    Get Frame Collection

    Hi
    I built a small tool in MS Access using a Form.

    When I click a button on this form, I want it to search for any opened Internet Explorer (IE) window at a specific url and then input some value into a field in the form of that HTML page's document. The HTML document has frames.

    I got the code to find the IE but now I am trying to get to the Frame collection on that HTML document.

    Can anyone help me?


    Thanks,

    P :oD

    Here is the code I use to find the IE window
    Code:
    'finds an open IE site by checking the URL
    Function GetOpenIEByURL(ByVal i_URL As String) As SHDocVw.InternetExplorer
    Dim objShellWindows As New SHDocVw.ShellWindows
    Dim obj  As Object 'SHDocVw.InternetExplorer.iframes
      'ignore errors when accessing the document property
      On Error Resume Next
      'loop over all Shell-Windows
      For Each GetOpenIEByURL In objShellWindows
        'if the document is of type HTMLDocument, it is an IE window
        If TypeName(GetOpenIEByURL.Document) = "HTMLDocument" Then
          'check the URL
          If GetOpenIEByURL.Document.URL = i_URL Then
            'we found the right window
            
            '---------
            'need code here to get to the frame collection
            
            '....
            
            '---------
            MsgBox "we found the right window"
            Exit Function
          End If
        End If
      Next
    End Function
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    It is my understanding that it would be something similar to:
    Code:
    Dim intFrameCounter As Integer
    
    For intFrameCounter = 0 To Document.Frames.Length - 1
      MsgBox Frames(intFrameCounter).Location.href
    Next

    Comment

    • pod
      Contributor
      • Sep 2007
      • 298

      #3
      thanks ADezii for answering to my query, I have yet to achieve my main goal, accessing the form elements to change their values for submittal of the form.

      I have made some headway but I still need help. See the code below .

      Thank you all in advance for your help. If I figure this one out on my own, I will post my result for everybody's benefit.

      P :oD

      Here is my updated code:

      Code:
      'finds an open IE site by checking the URL
      Function GetOpenIEByURL(ByVal i_URL As String) As SHDocVw.WebBrowser
          Dim i_URL As String
          Dim objIE As Object
          Dim objShellWindows As New SHDocVw.ShellWindows
          'some error handling
          On Error GoTo catchError
          'loop over all Shell-Windows
          Dim IEframes As FramesCollection
          For Each GetOpenIEByURL In objShellWindows
          'if the document is of type HTMLDocument, it is an IE window
          If TypeName(GetOpenIEByURL.Document) = "HTMLDocument" Then
              'check the URL
              If InStr(GetOpenIEByURL.Document.url, i_URL) > 0 Then
                  'we found the right IE window
                  
                  'now I capture the outer frame of the HTML document
                  Set IEframes = GetOpenIEByURL.Document.frames
                  ' and now I capture the inner frame
                  Set IEframes = IEframes.Item(0)
                  'this is the frame which contains the form
                  MsgBox IEframes(0).Name 'this is the one
                  
      '...so far so good
      'NEED THE RIGHT CODE HERE
      
                  'now I want to capture the form
                  '....Dim IEForm as GetTheElusiveFormCollection 
                  'and capture a text box in the form to set a value to it
                  '....Dim IEForm as GetTheElusiveFormFieldCollection 
      
      
      
      
                  Exit Function
              End If
          End If
          Next
      catchError:
          MsgBox Err.Description
      '    Call GetNewIE
      End Function
      p.s.
      God's speed to the people of Haiti and all the people who are helping out in any way or fashion

      Comment

      • pod
        Contributor
        • Sep 2007
        • 298

        #4
        Resolved

        FINALLY RESOLVED:
        taking a few days break from a problem, always helps

        here's the central missing portion

        Code:
        ...
        
        Dim IEframes As FramesCollection
            For Each GetOpenIEByURL In objShellWindows
                'if the document is of type HTMLDocument, it is an IE window
                If TypeName(GetOpenIEByURL.Document) = "HTMLDocument" Then
                    'check the URL
                    If InStr(GetOpenIEByURL.Document.url, i_URL) > 0 Then
                        'I capture the outer frame
                        Set IEframes = GetOpenIEByURL.Document.frames
                        'I capture the inner frame
                        Set IEframes = IEframes.Item(0)
                        'now I want to capture the form and its elements and set them for submital
                        IEframes(0).Document.Forms(0).SearchText.Value = 0
                        IEframes(0).Document.Forms(0).SearchWhat.selectedIndex = 1
                        IEframes(0).Document.Forms(0).HVQS_ACTION.Value = 1
                        IEframes(0).Document.Forms(0).submit
                        flag = True
                        Exit Function
                    End If
                End If
            Next
        Last edited by pod; Jan 21 '10, 03:06 PM. Reason: RESOLVED

        Comment

        Working...