FSO copy file returns permission denied

M

Madiya

I am trying to copy a file by fso by i am getting error 70 (permission denied).
I have admin rights on the pc.
Here is the code.

Sub COPY_INVOICES()
Dim inv As String
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
FILETO = InputBox("PL ENTER FULL PATH WHERE YOU WANT TO COPY FILES", "PATH")
FILEFROM = "C:\INVPDF\" & Range(A1").value & ".pdf"
fso.CopyFile FILEFROM, FILETO
End Sub

I am entering full path in inputbox.

Pl help to resolve.

Regards,
Madiya
 
T

Tim Williams

Possibly you don't have either the permissions required to read the original file, or the permissions required to write to the new location.

Tim
 
M

Madiya

Tim,
Thanks for reply.
I have admin rights on this PC.
I am able to copy, paste & delete in both the folders.
If I save any excel file in both folders, no problem.
This error comes up only while I use FSO in VBA.

Any thoughts?

Regards,
Madiya
 
M

Madiya

Dear all,
Pl help.

Regards,
Madiya

Tim,
Thanks for reply.
I have admin rights on this PC.
I am able to copy, paste & delete in both the folders.
If I save any excel file in both folders, no problem.
This error comes up only while I use FSO in VBA.

Any thoughts?

Regards,
Madiya
 
I

isabelle

hi,

did you add the reference to "Microsoft Scripting Runtime" (Tools / VBA references)

--
isabelle



Le 2012-04-11 10:37, Madiya a écrit :
 
J

Jim Cone

From the FileSystemObject help file...

object.CopyFile ( source, destination[, overwrite] )
CopyFile will fail if destination has the read-only attribute set.

Wildcard characters can only be used in the last path component of the source argument.
For example, you can use:
FileSystemObject.CopyFile "c:\mydocuments\letters\*.doc", "c:\tempfolder\"
But you cannot use:
FileSystemObject.CopyFile "c:\mydocuments\*\R1???97.xls", "c:\tempfolder"

If source contains wildcard characters or destination ends with a path separator (\),
it is assumed that destination is an existing folder in which to copy matching files.
Otherwise, destination is assumed to be the name of a file to create.
In either case, three things can happen when an individual file is copied.
? If destination does not exist, source gets copied. This is the usual case.
? If destination is an existing file, an error occurs if overwrite is false.
Otherwise, an attempt is made to copy source over the existing file.
? If destination is a directory, an error occurs.

An error also occurs if a source using wildcard characters doesn't match any files.
The CopyFile method stops on the first error it encounters.
No attempt is made to roll back or undo any changes made before an error occurs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top