Results 1 to 10 of 10

Thread: Unable to Get ElementID In VBA IE Automation

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,401
    Rep Power
    10
    If you can share screen using teamviewer, I can have a look after I am home.
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  2. #2
    Junior Member
    Join Date
    Mar 2013
    Posts
    20
    Rep Power
    0
    Hi fox thanks for the reply when you can be home im at office till 8:30 IST so if you get me some code to click on the tabel urls and to change combobox value
    in ie i checked from my end i am sucessuful to get the details of the buttons via inertext but not able to select value or change the selected index

    Just wanna let u know that its an url which i want a click to be send. i have done so far please help.

    Code:
    Public Sub ie_interface()
        Dim ie As Object
        
            Set ie = CreateObject("InternetExplorer.Application")
                   ie.navigate Sheet1.URL_text.Text
                  
           Sheet1.Pro_text1.Visible = True
           Sheet1.Pro_text2.Visible = True
        Application.ScreenUpdating = True
           cnt2 = Sheet1.Pro_text1.Width
           Do While ie.Busy
           If cnt < cnt2 Then
            Sheet1.Pro_text2.Width = cnt
            cnt = cnt + 2
            Application.Wait Now() + TimeValue("00:00:02")
           End If
           Loop
    
      Sheet1.Pro_text2.Width = cnt2
      Application.Wait Now() + TimeValue("00:00:02")
      Sheet1.Pro_text2.Width = 0
     cnt = 0
     cnt2 = 0
     
     Sheet1.Pro_text1.Visible = False
     Sheet1.Pro_text2.Visible = False
    ie.Visible = True
    Application.Wait Now() + TimeValue("00:00:02")
    ie.document.Login.UserName.Value = Sheet1.User_text.Text
    ie.document.Login.UserPassword.Value = Sheet1.Pass_text.Text
    ie.document.getElementById("Submit").Click
    
    Do While ie.Busy
    Loop
    Application.Wait Now() + TimeValue("00:00:01")
    Application.SendKeys ("%{ }X")
    Application.Wait Now() + TimeValue("00:00:01")
    ie.document.forms(0).all("m8").Click
    Application.Wait Now() + TimeValue("00:00:02")
    Application.SendKeys ("{TAB 3}")
    Application.Wait Now() + TimeValue("00:00:02")
    Application.SendKeys ("{TAB 4}~")
    Application.Wait Now() + TimeValue("00:00:02")
    
     Dim myHTMLDoc As HTMLDocument
        Set myHTMLDoc = ie.document
     
        'set myHTMLFrame2 as the 2nd frame of the main page (index starts at 0)
        Dim myHTMLFrame2 As HTMLDocument
        Set myHTMLFrame2 = myHTMLDoc.frames(0).document
     
        'set myHTMLFrame2_3 as the 3rd frame of myHTMLFrame2
        Dim myHTMLFrame2_3 As HTMLDocument
    '    Set myHTMLFrame2_3 = myHTMLFrame2.frames(1).document
     
        'get all the tables in myHTMLFrame2_3
        Dim allTables As Object
        Set allTables = myHTMLFrame2.getElementsByTagName("Table")
     
        'set myTable as the 3rd table in allTables
        Dim myTable As HTMLTable
        Set myTable = allTables(7)
     
         For Row = 1 To myTable.Rows.Length
            For Col = 1 To myTable.Rows(Row - 1).Cells.Length
            If myTable.Rows(Row - 1).Cells(Col - 1).innerText = "Data Extraction" Then
                myTable.Rows(Row - 1).Cells(Col - 1).Click 
              End If
            Next Col
        Next Row
        
        
        ie.Visible = True
    
    End Sub

  3. #3
    Junior Member
    Join Date
    Mar 2013
    Posts
    20
    Rep Power
    0
    At last i completed it with lots of R&D and googling i got it worked posted the code for your refrence.

    Code:
    Set myHTMLDoc = ie.document
            
      Set myHTMLFrame2 = myHTMLDoc.frames(0).document
      Set htmlDoc = myHTMLFrame2
    
        Set link = Nothing
        i = 0
        While i < htmlDoc.Links.Length And link Is Nothing
            If htmlDoc.Links(i).innerText = "Data Extraction" Then Set link = htmlDoc.Links(i)
            i = i + 1
        Wend
        If Not link Is Nothing Then
            link.Focus
            link.Click
        Else
            
        End If
        Set theFrame = Nothing

Similar Threads

  1. Replies: 17
    Last Post: 07-15-2013, 09:56 PM
  2. Replies: 1
    Last Post: 05-22-2013, 01:50 PM
  3. VBA IE Internet Explorer Automation Through ElementID
    By mrmmickle1 in forum Excel Help
    Replies: 3
    Last Post: 01-22-2013, 06:20 AM
  4. Replies: 7
    Last Post: 06-09-2012, 06:45 PM

Posting Permissions

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