I'm downloading an Excel file from particular website, but IE11 promoting me to click save button and I want it to automate using VBA.
I've tried Application.SendKeys("%s")
method but it didn't work since I'm not expert in VBA I can't go further.
Sub dailyreport()
Dim IE As Object
Dim doc As HTMLDocument
Dim Element As HTMLLinkElement
Set IE = New InternetExplorer
IE.Visible = True
IE.navigate ("https://mywebsite.com")
Do While IE.Busy
Application.Wait DateAdd("S", 1, Now)
Loop
Set doc = IE.document
doc.getElementById("login").Value = "username"
doc.getElementById("password").Value = "password"
doc.getElementById("loginButton").Click
' Navigate to report page Do While IE.Busy Application.Wait DateAdd ("S", 1, Now) Loop IE.navigate ("https://mywebsite.com/report") 'Since the hyperlink doesn' t have any link I 'm searching the link with href value (Export View)
Do While IE.Busy
Application.Wait DateAdd("S", 30, Now)
Loop
For Each Element In doc.Links
If InStr(Element.innerText, "Export View") Then
Call Element.Click
Exit For
End If
Next Element
End Sub
After clicking the Export View hyperlink it's starting to download but at the end IE asking me to click open or save button.
"Do you want to save or open"
So I wanted to click save button using VBA.