How to disable the message of IE asking open or save download file.
I just want to download it directly. no question asked.
How to disable the message of IE asking open or save download file.
I just want to download it directly. no question asked.
As far as I know, we can't disable the download prompt, but we could use the Application.SendKeys method to send the keystrokes of the shortcut keys (Alt + S) to click the save button in IE11.
Code as below:
Sub downloadfile()
Dim IE As Object, Data As Object
Dim ticket As String
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.navigate ("<the website url>")
While IE.ReadyState <> 4
DoEvents
Wend
Set Data = IE.Document.getElementsbyTagName("input")
'Trigger the download button to download the file
IE.Document.getElementbyId("btnDowloadReport").Click
'wait the download prompt appear
Application.Wait (Now + TimeValue("00:00:03"))
'
Application.SendKeys "%{s}"
'Waiting for the site to load.
'loadingSite
End With
Set IE = Nothing
End Sub
The web page content:
<a id="btnDowloadReport" href="https://research.google.com/pubs/archive/44678.pdf" download>Download</a>