View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
[email protected] brianatee@hotmail.com is offline
external usenet poster
 
Posts: 12
Default ie Command to Wait for "File Download" and "Save As" windows

I just tried Steve's code in place of my previous readystate commands
and unfortunately I get an error at Problems 2 and 3 at the line

Do While (ie.Busy)

On Jan 8, 3:22 pm, JP wrote:
Can you try the code Steve posted and let us know if it helps?

--JP

On Jan 8, 5:53 pm, wrote:

Thanks again for the help. Below is the code with the problems flagged
in comments. I have gotten through the first with a simple wait time,
but the speed of my connection varies greatly in terms of the wait at
Problems 2 and 3. I would like to avoid any other Application.Wait
(Now + TimeValue()) functions if possible.


______________________
Sub Basis()


Dim ie As Object
Dim nFile As Integer


Set ie = CreateObject("InternetExplorer.Application")


ie.Visible = True
ie.Navigate "http://www.nymex.com/settle_fut_otc.aspx"


Do Until ie.ReadyState = READYSTATE_COMPLETE
Loop


'Agrees with the Disclaimer form
If ie.LocationURL Like "*disclaimer*" Then
'Selects 'I agree'
ie.Document.Links(4).Click


'submits the form
ie.Document.getElementById("aspnetForm").submit


End If


'[PROBLEM 1 - wait time]
Do Until ie.ReadyState = READYSTATE_COMPLETE
Loop
'Readystate not enough, needed to add wait time
Application.Wait (Now + TimeValue("0:00:03"))


'clicks on "Download all available..."
ie.Document.all.Item("ctl00_btnExport").Click


'Saves the file to default location with default name
'[PROBLEM 2 - Wait for File Download Window]
Do While ie.ReadyState = 4
Loop


SendKeys "{LEFT}"
Application.Wait (Now + TimeValue("0:00:001"))
SendKeys "{ENTER}"


'[PROBLEM 3 - Wait for Save As Window]
Do Until ie.ReadyState = READYSTATE_COMPLETE
Loop
SendKeys "{ENTER}"


Do While Dir("[FILE LOCATION]") = ""
Loop
Do While FileLen("FILE LOCATION") = 0
Loop


ie.Quit


Workbooks.Open Filename:="FILE LOCATION", _


End Sub