Dextrious Dextrious - 1 year ago 369
HTML Question

IE automation VBA Excel find element by title

I am trying to get some information from a webpage using an excel macro, VBA.

I have the InternetExplorer.document object, but don't find a way to locate the exact info that I need.

The HTML part of what I am looking for looks like this:

<a title="BE - straat 70 - 3630 - Maasmechelen" class="leftalign floatleft" href="Page_companydetail.asp?vat=xxxxxxxxx" target="_blank">

 Oprichter van een onderneming natuurlijk persoon BE 

The information I want is the title here.
I tried a lot of things, but can't manage to single this element out and get the title.

1. Is there a way to get elements by title (Title starts with BE), or by class sinds this information is the only one on the page that has class "leftalign floatleft"

Answer Source

Yes ... knowing that the title is just another attribute of the <a> tag, you can cycle through all elements of concern using e.g.

HtmlDocument.GetElementsByTagName(String) method

and use the

HtmlElement.GetAttribute(String) method

to see if a title attribute exists and what's the value of it

see Reading Web Pages using Excel VBA for some more information

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download