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
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: