File copy

  • Thread starter Thread starter SkylineGTR
  • Start date Start date
S

SkylineGTR

Hi,

I would like to be able to put a button in a workbook to copy a file
from a web address to a location on my hard drive, but neither
FileCopy/CopyFile (API version)/ScriptingObject seem to be able to do
it.

I would like to do this:

CopyFile "http://a.b.c/test.xls","c:\test.xls"

Is it possible??

Cheers
 
try using the workbook.open event and then saving the file to your desired
location.
 
Thanks for the reply Don.

I have tried doing something similar, but I need to do a straight copy,
without opening the workbook/s.

I am stuck now.
 
Hi Don,

Found out how to do it and wanted to share with the group ..

Put the following in a module:

Private Declare Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As
String, _
ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As
Long) As Long

then create a wrapper:

Public Function DownloadFile(ByVal sURL As String, ByVal sLocalFile As
String) As Boolean
Dim lngRetVal As Long
DownloadFile = URLDownloadToFile(0&, sURL, sLocalFile, 0&, _
0&) = 0
End Function

then you can do:

DownloadFile("http://www.a.b.c/afile.zip","c:\afile.zip")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top