Hi,
I have a new project I was hoping someone could advise how to handle a couple issues.


The script below will do all of the following

Navigate to a webpage
Click a Javascript link relateing to a built in calendar on the webpage.
Click 2 Radio Buttons
Then Click a summit button

My first issue is how to make my code wait long enough for the next button to appear?

Currently I'm using the wait for 50 seconds but the time will always change depending on how much data is being collected. So is there a way for my code to know when the button shows up on the webpage?

Next Issue is After the button appears and is clicked a "File Download Pop Up Box" appears with options Open,Save and Cancel

How can I click the save button to save the file on a folder on my desktop?

Thanks for the help as always, Mike

Here is my code:
Sub ClickIE()
     
    Dim IE As Object
    Dim Monday As Date
    Dim StartDate As Date
    Dim Friday As Date
    Dim C As Integer
    
    
    Monday = MondayDate - 7: StartDate = "1/1/2000"
    Friday = Monday + 4
    C = (Monday - StartDate)
    D = (Friday - StartDate)
    
    Stop
    
    
    Set IE = CreateObject("internetexplorer.application")
     
    IE.Visible = True
     
    IE.Navigate "http://MYPAGE.aspx"
     
     'wait for page to load
    While IE.Busy
        DoEvents
    Wend
    'OLD WAY'IE.Document.parentWindow.execScript "javascript:__doPostBack('ctl00$MainContent$Calendar1','3985')"
    
    
    IE.Document.parentWindow.execScript "javascript:__doPostBack('ctl00$MainContent$Calendar1','" & C & "')"
    
    Application.Wait (Now + TimeValue("0:00:1"))
    
        IE.Document.getElementById("MainContent_RadioButtonList1_6").Checked = True
            Application.Wait (Now + TimeValue("0:00:1"))
                IE.Document.getElementById("MainContent_RadioButtonList2_0").Checked = True
                    Application.Wait (Now + TimeValue("0:00:1"))
     'click on run report button1
                IE.Document.getElementById("ctl00$MainContent$Button1").Click
    
    'Ready = IE.Document.all("").Value
     'wait for page to load
    While IE.Busy
            DoEvents
    Wend

    Application.Wait (Now + TimeValue("0:00:50"))
'Need to know when this button below shows up?
    
    IE.Document.getElementById("ctl00$MainContent$Button2").Click
  Stop
 
    'Need way to click the save button on file download box

     
End Sub