Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with FSO.CopyFile

Status
Not open for further replies.

omegabeta

Programmer
Aug 20, 2003
148
RO
Hi,

I'm trying to copy a file from a location to another.
In my script a have the following:
FSO.CopyFile lastf, DestFld & SubFld & lastMonth
I get the error "Permission denied"
Before that I've tried the following:
FSO.CopyFile destfld & "*.*", DestFld & SubFld & lastMonth
It works !

I must mention that I get the same error at work (administrative rights) and even at home !

Where is my mistake ?
 
Hello omegabeta,

The sensible conclusion from your description of the two separate cases one with wildcard and work, one without wildcard and failed. I would suspect your lastmonth string is not ending with backslash. Hence:
Code:
FSO.CopyFile lastf, DestFld & SubFld & lastMonth & "\"
regards - tsuji
 
FSO.CopyFile lastf, DestFld & SubFld & lastMonth
Can you please post the value of lastf, DestFld, SubFld and lastMonth ?
You may also consider to use the 3rd argument (True) of the CopyFile method in case the destination already exists.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Hi,
I've solve the problem. In the second example the correct command would have be:
FSO.CopyFile lastf, DestFld & SubFld & lastMonth & "\" & FileName

FileName was missing.

Thanks to all.
 
omegabeta,

Without FileName, you should be able to make the copy to the target directory with the same file name as lastf. Or, am I wrong here?!

- tsuji
 
omegabeta,

Just wanted to make sure what I said did not mislead you and to de-marking the thin-line among different behaviours copyfile is capable of. Thanks for your feedback.

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top