LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default Permission denied when copying file

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?

--
Ian
--


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
permission denied SandyR Excel Programming 2 November 16th 05 01:53 PM
error 70 - Permission denied MT Excel Programming 1 May 8th 05 07:20 AM
file delete in Excel receives permission denied by Server 2003 phurst Excel Programming 2 March 10th 05 09:43 PM
Permission to use object denied WilDeliver[_2_] Excel Programming 2 October 22nd 04 07:46 PM
Permission Denied Audrey Ng Excel Programming 1 October 1st 03 07:20 AM


All times are GMT +1. The time now is 10:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"