Consulting

Results 1 to 2 of 2

Thread: From IE to Excel

  1. #1
    VBAX Contributor
    Joined
    Nov 2009
    Posts
    114
    Location

    From IE to Excel

    What is the problems? Originally work well with below code


      Application.ScreenUpdating = False
        
        Dim objIe As Object, xobj As HTMLDivElement
        'Set objIe = CreateObject("InternetExplorer.Application")
         Set objIe = New InternetExplorerMedium
            
        objIe.Visible = True
        
    
        
        Dim id As Long
        Dim Lastrow2 As Long
        
        Sheets("main").Select
        With ActiveSheet
        Lastrow2 = .Cells(.Rows.Count, "A").End(xlUp).Row
        
        For  id = 2 To Lastrow2
        
        objIe.navigate "http://abc.com/id=" & Sheets("main").Cells(custid, 10).Value
    
       ' While (objIe.Busy Or objIe.READYSTATE <> 4): DoEvents: Wend
    While objIe.Busy: DoEvents
    Wend
    Do
    Loop Until Not (objIe.Busy)
    
                          
    Dim a As Long
                 
     For a = 1 To 8
             
            Set xobj = objIe.Document.getElementById("viewInfo_myApprDataGrid")
            Set xobj = xobj.getElementsByClassName("lfHead").Item(0)
            Set xobj = xobj.getElementsByTagName("td")(a)
            
            Sheets("1").Cells(1, a) = xobj.innerText
            
      Next a
      Next id
    
       Set xobj = Nothing
            objIe.Quit
            Set objIe = Nothing
             
               Application.ScreenUpdating = False

  2. #2
    VBAX Contributor
    Joined
    Nov 2009
    Posts
    114
    Location
    Quote Originally Posted by clif View Post
    What is the problems? Originally work well with below code


      Application.ScreenUpdating = False
        
        Dim objIe As Object, xobj As HTMLDivElement
        'Set objIe = CreateObject("InternetExplorer.Application")
         Set objIe = New InternetExplorerMedium
            
        objIe.Visible = True
        
    
        
        Dim id As Long
        Dim Lastrow2 As Long
        
        Sheets("main").Select
        With ActiveSheet
        Lastrow2 = .Cells(.Rows.Count, "A").End(xlUp).Row
        
        For  id = 2 To Lastrow2
        
        objIe.navigate "http://abc.com/id=" & Sheets("main").Cells(custid, 10).Value
    
       ' While (objIe.Busy Or objIe.READYSTATE <> 4): DoEvents: Wend
    While objIe.Busy: DoEvents
    Wend
    Do
    Loop Until Not (objIe.Busy)
    
                          
    Dim a As Long
                 
     For a = 1 To 8
             
            Set xobj = objIe.Document.getElementById("viewInfo_myApprDataGrid")
            Set xobj = xobj.getElementsByClassName("lfHead").Item(0)
            Set xobj = xobj.getElementsByTagName("td")(a)
            
            Sheets("1").Cells(1, a) = xobj.innerText
            
      Next a
      Next id
    
       Set xobj = Nothing
            objIe.Quit
            Set objIe = Nothing
             
               Application.ScreenUpdating = False

Posting Permissions

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