Automate file download from website with VBA, unable to bypass the windows save box

franunzio

New Member
Joined
Jun 23, 2013
Messages
2
Hi All,

I need to download a file from the web in CSV, the problem is that when the code click the bottom the file save window prevent the code from reaching the next line.
I check similar topic on this forum (see http://www.mrexcel.com/forum/excel-...ile-download-dialog-box-without-sendkeys.html) but the website I am dealing with required a manual intervention to click the save bottom any chance to fully automate it?(Code below):

Sub CodeStop()
Dim URL As String
Dim IeApp As Object
Dim ieDoc As Object
Dim ieForm As Object
Dim ieObj As Object
Dim objColl As Collection
Application.DisplayAlerts = False
URL = "http://www.bmreports.com/bsp/BMRSSystemData.php?pT=DDAD&zT=N&dT=NRT"


Set IeApp = CreateObject("InternetExplorer.Application")
IeApp.Visible = True
IeApp.Navigate URL


Do Until IeApp.ReadyState = READYSTATE_COMPLETE
Loop


Set ieDoc = IeApp.Document
For Each ele In IeApp.Document.getElementsByTagName("span")


If ele.innerHTML = "CSV" Then
Application.Wait (Now + TimeValue("0:00:15"))
DoEvents
ele.Click
'At this point you need to Save the document manually
' Code does not go to the next step until the save bottom is clicked



File_Download_Click_Save
End If


Next
''works but leads to the same problem
'For i = 0 To 2
''If IeApp.Document.getElementsByTagName("span").Item(i).getAttribute("Text") = "CSV" Then
'IeApp.Document.getElementsByTagName("span").Item(i).Click
'
''Else
'Debug.Print IeApp.Document.getElementsByTagName("span").Item(i).getAttribute("Title")
''End If
'
'Next i


'Version Build = 9002379
'TAB T=1
'TAB CLOSEALLOTHERS


'URL GOTO=http://www.bmreports.com/bsp/SystemPricesHistoric.htm
'frame Name = topFrame
'TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:sysPriceForm ATTR=NAME:dT CONTENT=2013-01-01
'TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:sysPriceForm ATTR=NAME:submit
'frame Name = bottom
'TAG POS=1 TYPE=SPAN ATTR=TXT:CSV




IeApp.Quit
End Sub

any suggestion?

Thanks in advance

Nunzio
 
Last edited:

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,214,657
Messages
6,120,764
Members
448,991
Latest member
Hanakoro

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