PDA

View Full Version : How to accept (Save) a file from IE 11?



prabhakaranK
06-13-2017, 01:20 AM
How to accept (Save) a file from IE 11?


Private Sub cmd_Submit_Click()
Dim myWebBrowser As New SHDocVw.InternetExplorer
With myWebBrowser
.Visible = True
.Navigate ("https://somewebsiteaddress")
Call WaitUntilDone(myWebBrowser)
With .Document
.GetElementByID("username").Value = "SomeUserName"
.GetElementByID("password").Value = "SomePassword"
.forms("f").submit
Call WaitUntilDone(myWebBrowser)
.GetElementByID("weekbox02").Click
.GetElementByID("donebutton").Click
Call WaitUntilDone(myWebBrowser)
.GetElementByID("filegenerator").Value = "CSV"
AppActivate "Photon Track - Internet Explorer"
Call .parentWindow.execScript("selectReportformat()", "JavaScript")
End With
End With
End Sub


Public Function WaitUntilDone(ByRef BrowserToWatch As Variant)
With BrowserToWatch
Do While .Busy: DoEvents: Loop
Do While .ReadyState <> 4: DoEvents: Loop
End With
End Function

selectReportformat() is sending a file to download. I am automating Internet Explorer 11. How to accept(save) the file?

The following code doesn't work

' Application.Wait (Timer + TimeValue("00:00:10"))' With Excel.Application
' .SendKeys "{TAB 2}", True
' .SendKeys "~", True
' End With

What's the right code to make it work? Possible without doing API Calls?