IE and DOM - Need to know when ALL documents have finished loading...

It seems like the document_complete event fires for every single document that is inside a parent document (I'm assuming documents in frames?).  I need to know when they all have finished loading.  Is there an easy way of doing this?  

Who is Participating?
are you using webbrowser control? if yes

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
if (pDisp = Webbrowser1) then
msgbox "all completed"
end if
End Sub
scottmichael2Author Commented:
No, I'm automating IE with SHDocVw.InternetExplorer (creating a new IE Window, navigating to a page, and then displaying the IE Window to the user).

Here is the exact situation...

I am attempting to get the parent DOM from pop-ups that occur.  So I have an IE object for the pop-up (and instanciate it when the parent's NewWindow2 event fires).  At the time that this fires, not all child documents are loaded.  So, I'm wanting to wait until all of them are loaded (by "watching" the DocumentComplete event of the pop-up).  I need them all to be loaded (not just the parent) so I can show pieces of HTML from the entire IE Window (not just the parent).  

I thought that the NavigateComplete2 event would handle this, but it looks like not all documents are completely loaded when this fires.

I tried the code above and it doesn't seem to work for what I'm doing.  It displays the message 3 times before the page actually is fully loaded.

Any other suggestions?

scottmichael2Author Commented:
For whatever reason, only the combination of the two checks worked (the one that you specifically posted and the one in the article above).  Thanks very much for your help!  Scott
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.