Consulting

Results 1 to 2 of 2

Thread: Automation error

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

    Automation error

    I run successfully in my computer

    IE: ver11
    EXCEL: 2010
    Microsoft Office 14.0 Object Library

    But cannot run in other computer
    IE: ver11
    EXCEL: 2013
    Microsoft Office 15.0 Object Library


    Sub abc()
    
        Application.ScreenUpdating = False
        
        Dim objIe As Object, xobj As HTMLDivElement
        Set objIe = CreateObject("InternetExplorer.Application")
        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 custid = 2 To Lastrow2
        
        objIe.navigate "http://www.abc.com/?=" & Sheets("main").Cells(id, 10).Value
    
    
          While (objIe.Busy Or objIe.readyState <> 4): DoEvents: Wend
            
        Sheets("1").Select
        Cells.Select
        Selection.Delete Shift:=xlUp
                     
    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
    Last edited by clif; 02-14-2017 at 09:46 PM.

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    try changing custid to id in the outer loop or id to custid in the cell reference.

    since id is declared as long and not assigned a value its value is 0. Cells(0, 10) throws error.
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

Posting Permissions

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