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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CopyFile error '70'

Status
Not open for further replies.

thegameoflife

Programmer
Dec 5, 2001
206
US
I can cut and past the file below manually, but when I try doing it in code I get run-time error ‘70’. Is there some way around this?

Code:
Function Copy_Amarillo()

Dim Filepath1, Filepath2 As String
Dim FS As Object

Filepath1 = "M:\Hmopmt2.xls"
Filepath2 = "C:\Recovery"

Set FS = CreateObject("Scripting.FileSystemObject")

    FS.CopyFile Filepath1, Filepath2

End Function


Run-time error ‘70’ Permission denied…..
 
Try doing it this way:

Filecopy Filepath1, Filepath2

Let me know if this helps. Regards,
gkprogrammer
 
nope. same error

what if the file is in use. would that cause the error?

If so, why do I not get the error when I manually copy the file?
 
This will not work correctly if the file is open otherwise it should work for you without a problem. I opened a file and then tried saving using this method while the file was still open and received the error 70 Permission Denied. So I am guessing that this is your problem. Regards,
gkprogrammer
 
i found the error

Code:
Filepath2 = "C:\Recovery"

should be

Code:
Filepath2 = "C:\Recovery\"

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top