Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting the link text from a URL source....almost there.

Status
Not open for further replies.

wraygun

Programmer
Dec 9, 2001
272
US
Hi all,

I'm using the following code from to get all of the links from a webpage into a listbox.

Code:
Dim objLink As HTMLLinkElement
Dim objMSHTML As New MSHTML.HTMLDocument
Dim objDocument As MSHTML.HTMLDocument


' This function is only available with Internet Explorer 5

Set objDocument = objMSHTML.createDocumentFromUrl(txtURL.Text, _
                                                  vbNullString)

' Tricky, to make the function wait for the document to
' complete, usually the transfer is asynchronous. Note
' that this string might be different if you have another
' language than English for Internet Explorer on the
' machine where the code is executed.

While objDocument.readyState <> "complete"
    DoEvents
Wend

' Source Code

Debug.Print = objDocument.documentElement.outerHTML

' Title

Debug.Print "Title : " & objDocument.Title

' Link Collection

For Each objLink In objDocument.links
    lstLinks.AddItem objLink
    Debug.Print "Link:  " & objLink
Next

This part is working perfectly.

I'm attempting to add the text from the webpage, into another listbox, that corresponds to the appropriate URL in the first listbox(from the code above). So, the listbox index, from both indexes will correspond with eachother.(text from webpage & appropriate url)

If I need to clarify any of the above, please let me know.

Any tips or pointers would be greatly appreciated.

Best regards,
Wray

***You can't change your past, but you can change your future***
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top