PDA

View Full Version : Excel crashes when calling Doc Readystate



yannickb
09-01-2010, 03:49 AM
Hi Everyone,

I Made a VBA Macro for Excel, the VBA script checks several websites for links, source code etc. I get the links out of the source code by doc.Links

Before the source-code is being downloaded I'm checking if the site is completely loaded. I perform this check by the following code:
While ((doc.readyState <> "complete"))
DoEvents
Wend

With hundreds of websites this is working correct, but several websites doesn't give a 'Complete'-status back. So i started to search for a solution which could fix this and added the following code:


Start = Timer

While ((doc.readyState <> "complete"))
If ((Timer - Start) > 30) Then
' Voer actie uit
Else
DoEvents
End if
Wend

So after 30 seconds the script would continue, but strangly enough several websites like these:
- f1pits.net
- fr-fans.nl

Keep giving problems, as soon as the script reaches
While ((doc.readyState <> "complete"))

Excel crashes completely and needs to be restarted, do you have any idea how i could fix this?

Thanks a lot!
Regards Yannick

Shred Dude
09-01-2010, 07:56 AM
I've noticed before that some Documents don't use the word "complete" but instead might use "4". You might try to include an OR in your code to check for readystate=4.

yannickb
09-02-2010, 06:34 AM
I've noticed before that some Documents don't use the word "complete" but instead might use "4". You might try to include an OR in your code to check for readystate=4.
Thanks for your answer,
but Excel keeps on crashing, even with the readystate=4 check.

yannickb
09-13-2010, 03:24 PM
I finally found out that the script already crashes at the:
Set doc = d.createDocumentFromUrl(url, vbNullString)

part instead of the doc.readystate part, strangely enough. Does anyone why Excel crashes when calling this function?

NomalAnomaly
09-13-2010, 04:20 PM
Can you show the entire code? I'll give it a try...