ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy A File From Internet To My Desktop (https://www.excelbanter.com/excel-programming/409713-copy-file-internet-my-desktop.html)

Edmund

Copy A File From Internet To My Desktop
 
What are the codes to copy a text file from the internet location
"http://www.myweb.com/myfolder/TheTextFile.txt" to my local C drive as
"C:\TheTextFile.txt"?

I tried FileCopy but to no avail.

Thanks in advance.

--
Edmund
(Using Excel 2000)

joel

Copy A File From Internet To My Desktop
 
Set fsmove = CreateObject("Scripting.FileSystemObject")

FName = "http://www.myweb.com/myfolder/TheTextFile.txt"

Set MyFile = fsmove.getfile(FName)
SName = MyFile.shortname

fsmove.CopyFile FName, "c:\" & SName

"Edmund" wrote:

What are the codes to copy a text file from the internet location
"http://www.myweb.com/myfolder/TheTextFile.txt" to my local C drive as
"C:\TheTextFile.txt"?

I tried FileCopy but to no avail.

Thanks in advance.

--
Edmund
(Using Excel 2000)


Edmund

Copy A File From Internet To My Desktop
 
Thanks for helping but I got "Run-time error '53': File not found" at line
"Set MyFile = fsmove.getfile(FName)"

I tested with:
FName = "http://www.cpearson.com/Zips/modActivateExcel.zip"

What's wrong?

--
Edmund
(Using Excel 2003 & 2000)


dan dungan

Copy A File From Internet To My Desktop
 
Hi Edmund,

I think it might be that a .zip file is not a .txt file.

Dan

poirot[_2_]

Copy A File From Internet To My Desktop
 
Hi Edmund, try this

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

Dim llRetVal As Long

Sub Download()
llRetVal = URLDownloadToFile(0, "http://www.cpearson.com/Zips/
modActivateExcel.zip", "c:\modActivateExcel.zip", 0, 0)

End Sub

______________________
Nuno Rocha

joel

Copy A File From Internet To My Desktop
 
I can't get Chip's file to download. chip may have access priviledges on his
file that doesn't allow copying the file. But try your code again except
remove the "http:" from the file name . I forgot when you access a file from
the web excel doesn't like the http

from
FName = "http://www.myweb.com/myfolder/TheTextFile.txt"
to
FName = "//www.myweb.com/myfolder/TheTextFile.txt"


"Edmund" wrote:

Thanks for helping but I got "Run-time error '53': File not found" at line
"Set MyFile = fsmove.getfile(FName)"

I tested with:
FName = "http://www.cpearson.com/Zips/modActivateExcel.zip"

What's wrong?

--
Edmund
(Using Excel 2003 & 2000)



All times are GMT +1. The time now is 11:34 PM.

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