Excel VBA to answer a dialogue box in Internet Explorer

EdwardAveyard

New Member
Joined
Feb 9, 2015
Messages
10
Hello. This is my first post. I'm sorry if this is a repetition. I have searched, but there are so many different dialogue boxes that it's hard to narrow it down to the sort that you're dealing with.

I am designing a macro to download about 300 CSV files from a secure website. (Unfortunately, I can't share the actual link with you, but it is a URL that loads a CSV file.) This is how far I've got. I'm doing this for one file first, and then doing the loop later on (which should be easy enough). It's the comment in capital letters where I'm stuck.


Sub VisitWebsite()
'Open the CSV file from the website
Dim ie As Object
Set ie = CreateObject("INTERNETEXPLORER.APPLICATION")
Application.DisplayAlerts = False
ie.NAVIGATE "CSV link"
ie.Visible = True
While ie.busy
DoEvents
Wend
'THIS IS WHERE I'M STUCK. THE DIALOGUE BOX COMES UP, AND I DON'T KNOW HOW TO AUTOMATE THE ANSWER.
'Copy and paste the data across
Windows("costs.csv").Activate
Range("D1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("Cost Savings Calculator VBA.xlsm").Activate
Range("C1").Select
ActiveSheet.Paste
'Close down the file
Windows("costs.csv").Activate
ActiveWindow.Close
End Sub

The dialogue box that opens from Internet Explorer has the title "View Downloads" and the only options are "Open and "Save". I want to select "Open". How do I do this?

Thank you in advance for your help.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
instead of:
Code:
ie.NAVIGATE "CSV link"
and the rest of the IE automation code, try opening (downloading) the .csv file directly with Excel:
Code:
Workbooks.Open "CSV link"
 
Upvote 0

Forum statistics

Threads
1,214,830
Messages
6,121,834
Members
449,051
Latest member
excelquestion515

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