Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / COM / February 2005



Tip: Looking for answers? Try searching our database.

Browser.Document.Links.Length is ...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jenda Krynicky - 15 Feb 2005 00:24 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.