ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   File copy (https://www.excelbanter.com/excel-programming/345264-file-copy.html)

SkylineGTR

File copy
 
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


Don Guillett[_4_]

File copy
 
try using the workbook.open event and then saving the file to your desired
location.

--
Don Guillett
SalesAid Software

"SkylineGTR" wrote in message
oups.com...
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




SkylineGTR

File copy
 
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.


SkylineGTR

File copy
 
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")



All times are GMT +1. The time now is 10:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com