I
IanC
The following code produces a permission denied error when trying to copy a
file.
Private Sub ReplaceDep(sCurPath, sTPPath)
Dim oFileSysObj As Object
Set oFileSysObj = CreateObject("Scripting.FileSystemObject")
' Following line gives "Permission denied (Error 70)"
oFileSysObj.CopyFile sCurPath & "\Deploy2.bat", sTPPath
End Sub
sCurPath and sTPPath are both valid paths and neither have any write
restrictions. The file to be copied exists, is not protected in any way and
is not open.
I've tried replacing the variable with hard coded paths. Out of desparation,
I've tried adding ", True" at the end of the line to force overwriting, even
though the filename does not exist in the destination folder and True is
default for the argument anyway.
I've never used CopyFile before so I may be missing something really obvious
(though not to me).
Using other code I am able to save an open XL file to the same folder
(sTPPath), so there's no problem writing to the folder with VBA.
Any ideas?
file.
Private Sub ReplaceDep(sCurPath, sTPPath)
Dim oFileSysObj As Object
Set oFileSysObj = CreateObject("Scripting.FileSystemObject")
' Following line gives "Permission denied (Error 70)"
oFileSysObj.CopyFile sCurPath & "\Deploy2.bat", sTPPath
End Sub
sCurPath and sTPPath are both valid paths and neither have any write
restrictions. The file to be copied exists, is not protected in any way and
is not open.
I've tried replacing the variable with hard coded paths. Out of desparation,
I've tried adding ", True" at the end of the line to force overwriting, even
though the filename does not exist in the destination folder and True is
default for the argument anyway.
I've never used CopyFile before so I may be missing something really obvious
(though not to me).
Using other code I am able to save an open XL file to the same folder
(sTPPath), so there's no problem writing to the folder with VBA.
Any ideas?