• Status: Solved
  • Priority: Low
  • Security: Public
  • Views: 52
  • Last Modified:

Object Variable or with block variable not set ERROR in VBA

Please see attached.

a.png
the error is in line
Set eleColtr = htmlTables(intTableIndex).getElementsByTagName("tr")

Open in new window

Book1.xlsb
0
Flora
Asked:
Flora
  • 3
  • 2
  • 2
2 Solutions
 
Fabrice LambertFabrice LambertCommented:
Instead of creating an Internet Explorer object, you'd better make a form with a web browser object, and catch the DocumentComplete event.

There is an article on MSDN:
https://support.microsoft.com/en-us/help/180366/how-to-determine-when-a-page-is-done-loading-in-webbrowser-control
0
 
FloraAuthor Commented:
Fabrice,

thanks, but led me on a wild-goose chase.  i cannot debug the code which i have and yet, how would i use the information on the link you shared.
0
 
Martin LissOlder than dirtCommented:
i cannot debug the code which i have...
Do you mean that you don't know how?
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
FloraAuthor Commented:
martin

i am not good at VBA.

currently my code shown in my OP. has an error. i do not know what it occurs and how to fix it.
0
 
Martin LissOlder than dirtCommented:
Please take a look at my article on debugging. If you have any questions about it please let me know.
0
 
Fabrice LambertFabrice LambertCommented:
Well, after some testing, it appear that the DocumentComplete event can' help as there are some javascript running once the document is loaded.

So, we have 3 solutions:
1) Export manually the result to excel (there is a link on the page for that), and import it into your application.
2) Contact United Nations, and ask them if they have any API or web services to automatically retrieve the datas.
3) Do the dirty way: Add a loop in your code, doing Nothing for like 5 or 10 seconds.
Insert the following after the loop waiting for the document to be loaded (WARNING: No garantees that it will always work !!!):
'// wait an additional 5 seconds
Dim dt As Date

dt = Now
While (DateDiff("s", dt, Now) < 5)
    DoEvents
Wend

Open in new window

0
 
FloraAuthor Commented:
thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now