VB Wait

M

MarkHear1

Hi All (again),

I now am faced with trying to make my macro wait for the new page to
finish loading when an option is selected.

My macro looks like this:

Dim ie As Object

Set ie = CreateObject("InternetExplorer.Application")

With ie
..Navigate "URL"
..Visible = True
Do Until .ReadyState = 4
DoEvents
Loop
End With

Set ipf = ie.Document.all.Item("p1_command")
ipf.Value = "my user name"
Set ipf = ie.Document.all.Item("pw1_command")
ipf.Value = "my password "
SendKeys "{ENTER}"

***Application.Wait Now + TimeValue("00:00:3")***
SendKeys "{Tab 2}", True
SendKeys "{ENTER}"

The line surrounded in *'s is the line i would like to change to make
check that the page has fully loaded rather than working on a timer.
If anybody can offer me some help i would appreciate it greatly!

Thank you,
Mark
 
D

Dave Miller

Mark,

Just add another loop, replace the application.wait line with this
loop:

Do Until ie.ReadyState = 4
DoEvents
Loop

David Miller

MarkHear1 wote:
 
M

MarkHear1

Hi Dave,

Thank you for this suggestion.
Unfortunately i won't be able to test it out until Monday now.
Will this work even if the button is question has opened a new window
and it's the new window that needs to finish loading?

Thanks,
Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top