Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub Test()
Dim fo As Object Set fo = CreateObject("Scripting.FileSystemObject") fo.CopyFile "C:\file1.txt", "C:\data\file1.txt", False End Sub Before you run the above code, create an empty directory of "C:\data". Oh course, "file1.txt" must exist on C: as well. If you run the above code once, file1.txt will successfully be copied into C:\data. However, run the code for a second time and you get a run-time error 58 message that says: "File already exists". Why does this error message appear? I've set the overwrite option to False, meaning do NOT overwrite. If I set the overwrite flag to True, the file inside C:\data never gets overwritten. No matter how many times I try. (Neither files are set to Read Only) So, I'm getting an error message when I use the False option. And, I'm unable to overwrite the file if I use the True flag. What is going on here???? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copyfile | Excel Programming | |||
FileSystemObject.copyfile | Excel Programming | |||
Help using FileSystemObject CopyFile | Excel Programming | |||
CopyFile usage | Excel Programming | |||
FileSystemObject CopyFile with UserID/Password | Excel Programming |