I need to write some VBA for excel to :
1)check if a file exists and delete it if it does.
2)Then download a file from a URL and time the length of the download and put this figure in a cell.
3)A bonus would be to be able to check that the filesize downloaded was the same as the URL filesize so that data rate could be calculated as well.
4) Possibly email the excel file?
I am very new to VBA and I can only seem to find code to check for the existence of a file and to delete it. My file download code below doesn't work. Is this something that is feasible and could someone help?
This is what I have so far:
1)check if a file exists and delete it if it does.
2)Then download a file from a URL and time the length of the download and put this figure in a cell.
3)A bonus would be to be able to check that the filesize downloaded was the same as the URL filesize so that data rate could be calculated as well.
4) Possibly email the excel file?
I am very new to VBA and I can only seem to find code to check for the existence of a file and to delete it. My file download code below doesn't work. Is this something that is feasible and could someone help?
This is what I have so far:
Code:
Sub Read_URL_Test()
Dim strDownFile As String
Dim strFilename As String
strDownFile = "URL;ftp://xxxxxxx.xxx"
strFilename = ("c:\test.fil")
If Len(Dir(strFilename)) <> 0 Then
Kill strFilename
End If
With ActiveSheet.QueryTables.Add(Connection:=strDownFile, _
Destination:="c:\test.fil") ' I have a type mismatch here
.BackgroundQuery = True
.TablesOnlyFromHTML = False
.Refresh BackgroundQuery:=False
.SaveData = True
End With
End Sub