Import Web Data to Excel using VBA Macros -- Object Variable not set error

0

Hi everyone,

Thank you for taking a look at my question. Having watched Youtube tutorial Import Web data into Excel using VBA Macros https://youtu.be/IOzHacoP-u4 I have run into the following problem:

"Run time error '91':

Object variable or With block variable not set"

Excel debug suggests problem is with the following line

price = html.getElementsByClassName("updated-text box-header ng-binding ng-scope ng-isolate-scope").Item(2).innerText

I have attached the code I am trying to run.

What I am trying to do is query the BA website to get infomation about a particular flight. I have tried a number of classes on the BA website but each time I get the same error.

Thank you for your help,

Alex

Answer
Discuss

Answers

0

When I use the url that you included in the macro no price shows up and I can't find that tag that you are searching for, which is probably why there is an error in the line of code that looks for a tag in the html.

I'd suggest getting a url that will for sure always return a price for a given flight - this one in your url might even be for a past flight, which could be the reason for the error.

Airline websites will be difficult to reliably query in this way, but I'd start by using a different url or by looking into their API's which would return the data as JSON.

Check this out: British Airways Developer Page

Discuss

Answer the Question

You must create an account to use the forum. Create an Account or Login