All,
I would like to download a file from IE 10 in the easiest way possible when not able to know the file name exactly. (server runs script to generate file on button click)
After opening IE and navigating to the web page, a predictable button is clicked. This button runs a server script which then IE prompts you with the Open/Save/Save As dialogue at the bottom of the page. After reading numerous posts on the subject I've tried URLDownloadToFile and ExecWB to no avail. What is the best approach to automate the download while saving to a defined location?
Is this possible without using hWnd? Is there a temporary internet file that is generated when the save dialogue box appears that I can grab without clicking save? If I can specify file save location using the hWnd commands I may consider it.
Thanks in advance!
I would like to download a file from IE 10 in the easiest way possible when not able to know the file name exactly. (server runs script to generate file on button click)
After opening IE and navigating to the web page, a predictable button is clicked. This button runs a server script which then IE prompts you with the Open/Save/Save As dialogue at the bottom of the page. After reading numerous posts on the subject I've tried URLDownloadToFile and ExecWB to no avail. What is the best approach to automate the download while saving to a defined location?
Is this possible without using hWnd? Is there a temporary internet file that is generated when the save dialogue box appears that I can grab without clicking save? If I can specify file save location using the hWnd commands I may consider it.
Thanks in advance!
Code:
Sub DownloadReports()
Dim IE As Object
Set IE = New InternetExplorerMedium
With IE
.Visible = True
.Navigate "URL.aspx"
'wait on the page to load
Do While .ReadyState <> 4
Sleep 50
Loop
IE.Document.getElementsByName("ctl00$ContentPlaceHolder1$btnExport").Item(0).Click
'wait on the file download window to appear
Do While .ReadyState <> 3
Sleep 50
Loop
Sleep 10
'download code here...
End With
End Sub