View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jake Marx[_3_] Jake Marx[_3_] is offline
external usenet poster
 
Posts: 860
Default Web page loading

Hi Matt,

You can do this if you are Automating Internet Explorer, but I don't know if
you can using AppActivate.

Here are the basics of doing it via Automation:

Sub test23()
Dim ie As InternetExplorer

Set ie = New InternetExplorer

ie.Navigate URL:="http://www.longhead.com/"

Do While ie.Busy Or Not ie.ReadyState = _
READYSTATE_COMPLETE
DoEvents
Loop

MsgBox ie.Document.body.innertext

ie.Quit
Set ie = Nothing
End Sub

You must set a reference to Microsoft Internet Controls in order to use
this. Or you can use Late Binding if you don't want to set a reference.

You can also sink the Internet Explorer events so you don't have to make the
user wait for the document to load - you can just call another subroutine or
take a specific action once the DocumentComplete event fires. This is a bit
tricky, but if you'd like to see some sample code, I'd be happy to post it
for you.

--
Regards,

Jake Marx
www.longhead.com


Matt Cohen wrote:
Does anyone have a non-time based vba code that allows vba
to detect when a web page has loaded after focus has been
thrown to Internet Explorer from Excel using Appactivate?

Currently I am inserting data from a text file into
specific fields on a web page and then pressing a button
on the page to receive the results. The results are then
saved using IE's "save as" function. However, since the
internet is not instantaneous, I need to have a way to
detect that the web page has been loaded. Using a timer
doesn't work since the amount of time is random and
assigning an estimated time means that the wait time has
to be adjusted every time this program runs.

Any advice about how to detect whether the page has loaded?

Thanks,

Matt