Assuming
Dim Browser As SHDocVw.InternetExplorer
and that the Browser is created, initialized and a page is loaded
Browser.Document.Links.Length
is the number of links in the loaded page, right?
WRONG !
As soon as there is ANYTHING in the page with id="links" (the case of the id
doesn't matter) this throws an error (if you are lucky) or returns the
number of items in the object with that id. Because the object hides the
Links property of the Browser.Documents object. So instead of having a
DispHTMLElementCollection containing the links you end up with eg. a
HTMLImg.
I'll snip the name calling and ask right away ... is there any way to
prevent this? And no I can't change the page that gets loaded.
Thanks a lot, Jenda
P.S.: A mail CC: would be much appreciated.
Dick Kusleika - 17 Feb 2005 16:41 GMT
Jenda
That's interesting. You could loop through all the elements instead of just
the links.
For i = 1 To ieApp.Document.all.Length
If TypeName(ieApp.Document.all(i)) = "HTMLAnchorElement" Then
Debug.Print ieApp.Document.all(i).innertext
End If
Next i
That's going to be slower than using the links collection, but it should
work.

Signature
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com
> Assuming
> Dim Browser As SHDocVw.InternetExplorer
[quoted text clipped - 16 lines]
> Thanks a lot, Jenda
> P.S.: A mail CC: would be much appreciated.
Jenda Krynicky - 24 Feb 2005 22:19 GMT
> Assuming
> Dim Browser As SHDocVw.InternetExplorer
[quoted text clipped - 15 lines]
>
> Thanks a lot, Jenda
It seems I screwed up somehow when testing this. After some more tests it
seems to happen only for name="" attributes to <IMG>.
Probably there will be others, but this is an example that gives be this
problem.
<html>
<body>
<img name="Links" src="http://www.google.com/images/logo.gif">
<a href=".">a link</a>,
<a href=".">a link</a>,
<a href=".">a link</a>,
<a href=".">a link</a>,
<a href=".">a link</a>,
<a href=".">a link</a>
</body>
</html>
Jenda