I'm trying to import information from a website. I think I know how to do what I want to do, but the code works intermittently. I can run the macro 10 times back to back, and it import varying amounts of data each time before the error will come up. The error (Run-time error'91': Object variable or With block not set) seems to be related to
Code
Set objCollection = ie.document.getElementsByTagName("b")
i = objCollection.Length - 1
Range("B2").Value = objCollection(i).innerText
Though if i comment out that particular section, the error just comes on the next object declaration. Any thoughts on why this would work sometimes but not others? The code I use to set up my Internet explorer object is as follows
Code
Set ie = CreateObject("InternetExplorer.Application"
ie.Navigate "http://scores.covers.com/basketball-scores-matchups.aspx"
Application.StatusBar = "Scores are loading. Please wait..."
Do While ie.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
But I don't think thats the problem, that's worked for me for other things before. Let me know what you think