Thread: Move a file
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Otto Moehrbach[_2_] Otto Moehrbach[_2_] is offline
external usenet poster
 
Posts: 1,071
Default Move a file

Thanks Dana. Otto
"Dana DeLouis" wrote in message
...
I want to move (not copy) a file from one folder to another folder.
... and I got a #70 error "Permission denied"


As a side note, you will also get #70 error "Permission denied" if you
give a destination without a trailing "\" character to indicate it's a
folder.

Sub Demo()
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.MoveFile "C:\Junk A\Dummy.txt", "C:\Junk B\"
End Sub

--
HTH :)
Dana DeLouis


"Otto Moehrbach" wrote in message
...
Duh! The Test.xls file was open and that created the "Permission Denied"
error. I closed the file and the code copied the file. I then changed
the
FileCopy line to:
Name PathSource & FileName As PathDest & FileName
and all was well. Thanks anyway. Otto
"Otto Moehrbach" wrote in message
...
Excel XP & Win XP
I want to move (not copy) a file from one folder to another folder. I
tried the following test macro and I got a #70 error "Permission denied"
on the "FileCopy" line of code. What is the proper code to move a file?
Thanks for your time. Otto
PS: My computer is a sole home computer, not hooked up to any network
at
all.
Sub TestMove()
Dim PathSource As String
Dim PathDest As String
Dim FileName As String
PathSource = "C:\ASource\"
PathDest = "C:\ADest\"
FileName = "Test.xls"
FileCopy PathSource & FileName, PathDest & FileName
End Sub