Hyperlink Elements in HTML

the code below will get all the hyperlink elements.

Function hyperlinkInformation()
Dim IE As Object
Dim doc, element
Set IE = CreateObject(“InternetExplorer.Application”)
    IE.Navigate “http://www.google.com
    Set doc = IE.Document
        Dim i As Integer
        i = 1
        For Each element In doc.all.tags(“A”)
            MsgBox = element.innertext ‘prints the text of the hyperlink
            MsgBox = element ‘prints the hyperlink itself
            ‘press ctrl-g to see debug window
            i = i + 1
        Next element
End Function

The following code will get all the hyperlink controls on html document printed on the activesheet if run through ms excel.
Function hyperlinkInformation()
Dim IE As Object
Dim doc, element
Set IE = CreateObject(“InternetExplorer.Application”)
    IE.Navigate “http://www.google.com
    Set doc = IE.Document
        Dim i As Integer
        i = 1
        For Each element In doc.all.tags(“A”)
            Cells(i, 1) = element.innertext ‘prints the text of the hyperlink
            Cells(i, 2) = element ‘prints the hyperlink itself
            ‘press ctrl-g to see debug window
            i = i + 1
        Next element
End Function

Advertisements

1 Comment »

  1. […] Hyperlink Elements in HTML […]

RSS feed for comments on this post · TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: