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

1 Comment »

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

RSS feed for comments on this post · TrackBack URI

Leave a Comment

You must be logged in to post a comment.