IE 10 File Download from Server Script

ddmx488

New Member
Joined
Jun 27, 2014
Messages
9
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!

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
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,215,400
Messages
6,124,702
Members
449,180
Latest member
craigus51286

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top