+ Reply to Thread
Results 1 to 4 of 4

VBA Internet Explorer Automation using frames

Hybrid View

  1. #1
    Registered User
    Join Date
    02-01-2011
    Location
    Philadelphia, Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    57

    VBA Internet Explorer Automation using frames

    i've tried this for awhile now and feel as though im close just missing something. the website i'm trying to enter data into is an electronic document system and is based on a server here at work so i wont be able to send anyone a link as you wouldnt be able to access it. however i have gone through the html to find certain pieces of info i need. the site is split into 10+ frames (i believe) the frame im looking to reference is labeled "frameSearchCriteria" (both name & id) (also form name is "xForm" if thats relevant) the field i'm trying to have data input in to is "xObjectSearchId" (name). this is what i have so far, not sure how to identify the specific frame, and form if necessary. please help!

    Sub Xdoc()
       
    
        Dim oIE As InternetExplorer
        Dim HTMLDoc As HTMLDocument
        Dim frmCol As FramesCollection
        Dim htmlColl As Object
        Dim htmlInput As Object
        
        
        Set oIE = CreateObject("InternetExplorer.Application")
        oIE.Navigate ("http://imaging/xsuite/xapps/default.aspx")
        
        Do While oIE.Busy: DoEvents: Loop
        Do While oIE.readyState <> 4: DoEvents: Loop
        
        oIE.Visible = True
    
         ' Go through <frame> to get to main document
        Set frmCol = oIE.document.frames 'Get the frame collection
        Set HTMLDoc = frmCol.Item(1).document 'Get the HTML document within the frame
        Set htmlColl = HTMLDoc.getElementsByName("xObjectSearchId") 'Get the input collection from this HTML doc
        For Each htmlInput In htmlColl
            If htmlInput.Name = "xObjectSearchId" Then htmlInput.Value = ("4212080657")
        Next htmlInput
        
        Set oIE = Nothing
    
    End Sub

    Moderator's Note: Welcome to the forum, You have to put code tags around code. Select the codes then hit the "#"
    Last edited by vlady; 11-14-2012 at 09:00 PM. Reason: code tags

  2. #2
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: VBA Internet Explorer Automation using frames

    It should be something like:
    Set YourFrameObjectVariable = IE.Document.getElementById("TheFrameId")
    Set HTMLdoc = YourFrameObjectVariable.contentWindow.Document
    'HTMLdoc now has frame content
    Post responsibly. Search for excelforum.com

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: VBA Internet Explorer Automation using frames

    Does this work?
    Set frmColl = oIE.document.frames
    
    For Each frm in frmColl
    
          If frm.Name = "frameSearchCriteria" Then
                 Set HTMLDoc = frm.Document
                 Exit For
          End If
    
    Next frm
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    02-01-2011
    Location
    Philadelphia, Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: VBA Internet Explorer Automation using frames

    neither worked. I'm getting a Run Time 438 object doesn't support this property or method. here's what I have so far.

    Sub xdoc()
      
     
        Dim oIE As InternetExplorer
        Dim HTMLDoc As HTMLDocument
        Dim frmCol As FramesCollection
        Dim htmlColl As Object
        Dim htmlInput As Object
       
        
        Set oIE = CreateObject("InternetExplorer.Application")
        oIE.Navigate ("http://imaging/xsuite/xapps/default.aspx")
       
        Do While oIE.Busy: DoEvents: Loop
        Do While oIE.readyState <> 4: DoEvents: Loop
       
        oIE.Visible = True
     
        
        Set frmCol = oIE.document.frames
        For Each frm In frmCol
         If frm.Name = "frameSearchCriteria" Then
        Set HTMLDoc = frm.document
        Exit For
        End If
        Next frm
        Set htmlColl = HTMLDoc.getElementsByName("xObjectSearchValue")
        For Each htmlInput In htmlColl
            If htmlInput.Name = "xObjectSearchValue" Then htmlInput.Value = ("4812090037")
        Next htmlInput
           
         Do While oIE.Busy: DoEvents: Loop
        Do While oIE.readyState <> 4: DoEvents: Loop
     
        Set oIE = Nothing
     
    End Sub
    Last edited by kboy1289; 11-16-2012 at 04:45 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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