I'm trying to download a zip file from a public web site http://serviciosede.mineco.gob.es/indeco/BDSICE/homebdsice.aspx.
To download the file this site executes a piece of javascript javascript:__doPostBack('lbutton_BdsiceCompleta',").
I have been downloading manually by clicking on this button, but I would like to do it via Excel VBA.
I'm stuck at retrieving the zip file.
Dim StrWebpage As String
StrWebpage = "http://serviciosede.mineco.gob.es/indeco/BDSICE/homebdsice.aspx"
Dim objIE As SHDocVw.InternetExplorer 'microsoft internet controls (shdocvw.dll)
Dim HTMLDoc As MSHTML.HTMLDocument 'Microsoft HTML Object Library
Dim htmlInput As MSHTML.HTMLInputElement
Dim htmlColl As MSHTML.IHTMLElementCollection
Set objIE = New SHDocVw.InternetExplorer
With objIE
.Navigate StrWebpage ' Main page
.Visible = 1
Do While .Busy: DoEvents: Loop
Do While .ReadyState <> 4: DoEvents: Loop
Set HTMLDoc = .Document
Set objIE = New SHDocVw.InternetExplorer
Set frame = HTMLDoc.getElementsByName("lbutton_BdsiceCompleta")
Call frame.execScript("lbutton_BdsiceCompleta", "JavaScript")
End With