PDA

View Full Version : Looping until a Frame is ready?



igotgame
03-16-2009, 03:47 PM
Guys I am using Excel and am exporting data to a Web Form...well these forms are in Frames and this is the issue or situation I would like to get around:

This works great(no this isn't all the code):


With objIE
Do While .Busy: DoEvents: Loop
Do While .ReadyState <> 4: DoEvents: Loop

When the page contains no frames.

Now...How can I tell Excel/VBA to wait until the FRAMES readystate <> 4? The page will load and it will attempt to enter the data, but the FRAME hasn't loaded yet.

I am using this for now:


Application.Wait (Now() + TimeValue("00:00:02"))

But I feel that is sloppy because the frame doesn't load at the same speed on my crap work connection each time.

Anyone have any ideas how to adjust


Do While .Busy: DoEvents: Loop
Do While .ReadyState <> 4: DoEvents: Loop


For a frame?

I have attempted this to no avail:


Do While .Document.frames("DataFrame").Busy: DoEvents: Loop

This is one of my frames for example

Set htmlDoc = .Document.frames("DataFrame").Document



Also with regards to Javascript...

I have this function working:

Call .Document.frames(i).execScript("save()", "JavaScript")

This pops up a Save dialog box and ask "Do you want to save?" Yes or No. Well is there anyway to automate it so that the answer is always yes? I can click the box manually but I would rather have it just be yes all the time.

Oorang
03-20-2009, 05:03 PM
Well as always, it's a lot easier to answer those type of questions if we have the URL;) But the high level version goes something like this:
Set a reference to MSHTML.
Get after your wait loop. Get the document object from the IE object.
Loop until the document object is not nothing.
Get the frame object from the document object.
Loop until the frame object is not nothing.
Should be loaded at that point:)