I'm getting tables from a website. I may have to wait for the site to open, I used Do While tbls(i) Is Nothing.
But if I get a permission denied, Is Nothing doesn't work.
I tried : If iserror(tbls(i)) Then, But if permission denied, iserror is not working either.
I know that if I could catch the error like : resume next and wait few second, It would work.
But I can not catch the error.
Any advise would be helpfull. Thank you
Sub Trouve()
With appIE
.Navigate sURL
Do While appIE.Busy: DoEvents: Loop
End With
Set doc = appIE.Document
Set tbls = doc.getElementsByTagName("TABLE")
If iserror(tbls(i)) Then
Application.Wait Now + TimeValue("00:00:10")
Set tbls = doc.getElementsByTagName("TABLE")
End If
Do While tbls(i) Is Nothing
Application.Wait Now + TimeValue("00:00:03")
Loop
GetTableData tbls(i), Worksheets("Work").Range("A" & Rows.Count).End(xlUp).Offset(2)
End Sub
But if I get a permission denied, Is Nothing doesn't work.
I tried : If iserror(tbls(i)) Then, But if permission denied, iserror is not working either.
I know that if I could catch the error like : resume next and wait few second, It would work.
But I can not catch the error.
Any advise would be helpfull. Thank you
Sub Trouve()
With appIE
.Navigate sURL
Do While appIE.Busy: DoEvents: Loop
End With
Set doc = appIE.Document
Set tbls = doc.getElementsByTagName("TABLE")
If iserror(tbls(i)) Then
Application.Wait Now + TimeValue("00:00:10")
Set tbls = doc.getElementsByTagName("TABLE")
End If
Do While tbls(i) Is Nothing
Application.Wait Now + TimeValue("00:00:03")
Loop
GetTableData tbls(i), Worksheets("Work").Range("A" & Rows.Count).End(xlUp).Offset(2)
End Sub