View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Tim Williams Tim Williams is offline
external usenet poster
 
Posts: 1,588
Default HTML Document.Links Issues

Gregg,

I'm at work right now so can't give you any comprehensive advice on how to
proceed. It's enough to say that what you're trying to do isn't very simple
if you want to be able to handle all possible outcomes.

You can easily check what happens with a 404 just by starting with a
non-existent URL. I haven't tried with pages which pop up a prompt so
couln't say what will happen other than your routine will hang at this
point.

File extensions: very tricky given the number of possible values. You could
decide only to follow htm, html, shtml, etc and ignore any others, but as
you note it's not always possible to tell from looking at the URL what will
be returned. As you note, it shouldn't cause an error, but not much point in
following refs which will not have links.

Re your saving of the links collection: you have to actually copy the links
to another object: by just setting a variable to point to the links
collection you are just creating a *reference* to the collection, not making
a copy of it. Since the collection only exists in the context of the loaded
page, you will lose your connection when you reload the page. "Access
denied" is the typical response to cross-domain access violations so IE may
have interpreted your actions in this context.


Tim

--
Tim Williams
Palo Alto, CA


"Gregg Roberts" wrote in message
...
Tim,

This is awesome! Thank you so much.

Since you've been so helpful, I'm going to ask you a few more questions.
Obviously you're free to say "enough" at any point. I think these

additional
questions still fit my subject line...

1. Are there other ReadyStates that I should handle besides
READYSTATE_COMPLETE? What if an OK/Cancel prompt appears upon navigation,
such as "You are about to visit a page that has unsecure items..." Will

that
give ReadyState = READYSTATE_INTERACTIVE? What about a 404 error -- will

that
still give READYSTATE_COMPLETE?

2. What if a link href is to a non-HTML file such as a .WMV, .DOC, or

..PDF?
I don't want the macro to try to visit such links, even though it should

not
cause an error on my machine. Short of building and maintaining a list of
what file types to visit or not, how do I determine whether to navigate to
the URL? Parsing the file extension is not straightforward because of

active
pages, which can contain spurious "file extension" matches.

I really want this code to be robust and there's a lot to think about.

Gregg Roberts

P.S. I was already saving the links collection to a variable, LinkTags1 --
not just accessing it via IEDoc.Links. However, if I navigate to a new

page
without setting IEDoc = IEApp.Document, why would IEDoc.Links be affected

at
all -- much less be made *inaccessible*? Remember, the error message was
Permission Denied, not Object Required, Object Does Not Exist, or some

more
generic error.

P.P.S. Where can I read more about how all this works? The MSDN site seems
to refer to a lot of environments I am not using, hence the examples don't
work.