Hi Ray,
How about:
Dim HLink As Hyperlink
objDocument.Range.AutoFormat
For Each HLink In objDocument.Hyperlinks
If Left(HLink.Address, 7) = "mailto:" Then
....
End If
....
Next
Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------
"Ray C"
> I'm writing a Word VBA function that process hyperlinks within word
> documents. Since Work can also convert web sites into hyperlinks as well, I
> check that the Hyperlink.Address property begins with "mailto" to make sure I
> only process email addresses.
>
> Here's a sample of my code:
>
> objDocument.Range.AutoFormat
> For Each HLink In objDocument.Hyperlinks
> E_Mail = Split(HLink.Address, ":", 1)
> If E_Mail(0) = "mailto" Then
> ....
> Endif
> ......
> Endif
>
> The problem is that I get an error on the third line, telling me that
> Hyperlink has been deleted. Yet I clearly have two email addresses in the
> document. In other cases I get a different error message saying that the
> Address method of object Hyperlink failed (caused by the same line, the third
> line).
>
> When I step code during debugging, I get 2 for objDocument.Hyperlinks.Count
> which is what I'm supposed to get since there are 2 hyperlinks in the
> document.
>
> Can anyone shed some light on this?
>
> Thanks in advance
>
> Ray
>