Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

file copy does not work

  Asked By: Madison    Date: Mar 14    Category: MS Office    Views: 1002
  

I have an intranetpage containing newer file revs for an Add-in (an XLS file, a
help file, a help content file). When trying to copy the updated files from the
intranet to my Excel Libray folder I get error 52 (bad file name or number). I
use the following code:

Const FHlp = "http://xxx.zzz.com/tools/test_me.xls"
ELP = Application.LibraryPath & Application.PathSeparator
Set FObject = CreateObject("Scripting.FileSystemObject")
FObject.CopyFile FHlp, ELP & "test.xls", True

When I replace FHlp with a path on my C-drive or a LAN drive, copy works fine.
And I can open this file at the intranet when replacing the last code line by:
ThisWorkbook.FollowHyperlink FHlp

For the Excel file it would be possible to open it and then save, but this
doesn't work for the HLP and CNT files.
Any idea how to copy files from our intranet to my Excel Libray folder?

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Douglas Sullivan     Answered On: Mar 14

The FileSystemObject only knows how to do copy  operations to the native
file system including CIFS file  systems (Common Internet File System or
Windows Network Sharing) because CIFS provides a mechanism for treating a
network location as a drive.

In your example, though, you're attempting to retrieve a file using the
HTTP protocol and the FSO simply doesn't know how to retrieve that kind of
file. That's why you're getting the 52 Error.

I'd suggest you either work  with a drive  mapped to the Intranet location
or go to http://msdn.microsoft.com and investigate the use of the XMLHTTP
object.

 
Didn't find what you were looking for? Find more on file copy does not work Or get search suggestion and latest updates.




Tagged: