Quantcast
Channel: Internet Explorer Web Development forum
Viewing all articles
Browse latest Browse all 3527

How to assign the value of "href" attribute of element "a" to a string variable in VBA macro by methods getElementsByClassName and getAttribute

$
0
0

Suppose that the body tag of the HTML file only includes the following element "a" in the source code of the HTML file:

<a href="http://www.microsoft.com">Microsoft</a>

I want to return the element "a" based on the value of theclass attribute and return the value of thehref attribute of the returned element "a" and store the value of thehref attribute (URL) in a string variableby methods getElementsByClassName andgetAttribute.
In other words, I want to know how is the correct declaration and definition of these methods and related variables.

Could anyone suggest a sample code having all definitions and declarations of these methods and related variables.

I am working on the following code, but it did not work and resulted to error.

Dim IE As Object
Set IE = CreateObject("internetexplorer.application")
Dim doc As HTMLDocument

Dim strAddress As String

Set WebSiteURL = doc.getElementsByClassName("rdwebsite mb0 fRight")

Set strAddress =  WebSiteURL.getAttribute("href")




Viewing all articles
Browse latest Browse all 3527

Trending Articles