Retrieve web page Title from URL

  • Thread starter Thread starter Chris Kinata
  • Start date Start date
C

Chris Kinata

Hi all,

I'd like to click a button on my Contact form that takes a
web page URL, retrieves the <title> element from the website,
and puts it into another Contact field.

Can anyone point me to an OL VBA example that can grab
a <title> associated with a URL?

Regards,
Chris
 
Am Thu, 6 Oct 2005 10:35:53 -0700 schrieb Chris Kinata:

Chris, this sample should do it. Please add references on "Microsoft
HTML Object Library" and "Microsoft Internet Controls" to your project.

Public Sub LoadWebsite()
Dim ie As SHDocVw.InternetExplorer
Dim docHtml As MSHTML.HTMLDocument
Dim sUrl As String

sUrl = "www.kathrin-kutz.de/index.php"
Set ie = New SHDocVw.InternetExplorer
ie.navigate sUrl
Set docHtml = ie.Document
Debug.Print docHtml.Title
End Sub
 
Hi Michael,

Ran this code and got the runtime error

-2147467259 (80004005)
Automation error
Unspecified error

on the statement

Set docHtml = ie.Document

I've added references to
Microsoft HTML Object Library
Microsoft Internet Controls

in the Visual Basic editor within Outlook.

I've Googled this and see some indication that it's associated with
permissions failure. Perhaps there's a zone problem with running this
code in an OL module.

Another idea I had after poking around in the MSDN docs on
Reusing the Browser is that perhaps it would be necessary
to wait until the NavigateComplete2 event fires--maybe
..Document isn't there yet.

Best Regards,
Chris

p.s. Nice paintings!
 
Am Thu, 6 Oct 2005 15:15:37 -0700 schrieb Chris Kinata:

Chris, using the Complete event is surely a good idea. Please tell us if it
works then.

(Thanks about the paintings! I´m going to tell it the artist.)
 
Back
Top