Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Timing an internet download

Status
Not open for further replies.

sdfern5

IS-IT--Management
Jun 24, 2003
3
GB
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:
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top