Hi,
 
I've written a code to navigate from one webpage to another and getting the 
table from the second webpage. Sometimes its getting the table value and 
sometime I'm getting
Object variable or with block variable not set error. I think while setting 
the line Set doc = ie.Document, 'm getting the error. Please help me out in 
resolving.
 
Sub getData()
dataarr = Range("A2:A4") 'Change according to your criteria
    For I = 1 To UBound(dataarr, 1)
    If counter = 0 Then
        store_value = dataarr(I, 1)
        counter = 1
        MsgBox store_value
    Else
        store_value = store_value & Chr(13) & dataarr(I, 1)
    End If
    Next
    MsgBox store_value
Dim ieApp As InternetExplorer
    Dim doc As Object
    Dim ie As Object
    
    
    Set ie = CreateObject("InternetExplorer.application")
    ie.Visible = True
    ie.navigate "
http://BizSolo/OrderProcessStatusQuery/EnterQuery.jsp?dummy=false";
    Do
    Loop Until ie.readyState = READYSTATE_COMPLETE
    Application.Wait DateAdd("s", 3, Now)
    While ie.Busy
    DoEvents
    Wend
    ie.Document.getElementById("SB_Name").Click
    ie.Document.getElementById("SB_Name").Click
    Application.Wait (Now + TimeValue("0:00:10"))
    ie.Document.getElementById("orderNumber").Value = store_value
    Application.Wait (Now + TimeValue("0:00:1"))
    ie.Document.getElementById("SB_Name").Click
    Do
    Loop Until ie.readyState = READYSTATE_COMPLETE
    Application.Wait DateAdd("s", 3, Now)
    While ie.Busy
    DoEvents
    Wend
    Application.Wait (Now + TimeValue("0:00:30"))
    
    Set doc = ie.Document
    Call GetAllTables(doc)
  
End Sub

                    
Sub GetAllTables(doc)
             
             ' get all the tables from a webpage document, doc, and put 
them in a new worksheet
             
            Dim ws As Worksheet
            Dim rng As Range
            Dim tbl As Object
            Dim rw As Object
            Dim cl As Object
            Dim tabno As Long
            Dim nextrow As Long
            Dim I As Long
             
            Set ws = Worksheets.Add
             
            For Each tbl In doc.getElementsByTagName("TABLE")
                tabno = tabno + 1
                nextrow = nextrow + 1
                Set rng = ws.Range("B" & nextrow)
                rng.Offset(, -1) = "Table " & tabno
                For Each rw In tbl.Rows
                    For Each cl In rw.Cells
                        rng.Value = cl.outerText
                        Set rng = rng.Offset(, 1)
                        I = I + 1
                    Next cl
                    nextrow = nextrow + 1
                    Set rng = rng.Offset(1, -I)
                    I = 0
                Next rw
            Next tbl
             
            ws.Cells.ClearFormats
             
        End Sub
 
 

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to