FileSystemObject Remane file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Function NFile()
Dim FSO As FileSystemObject
Set FSO = New FileSystemObject

FileSystemObject.Renamefile "C:\Test.txt", "SecondTest.txt", False

End Function

I just want to rename a file in the directory from access.

I get this run-time error 424 Object required.

Thanks in advance for any help
 
No need to resort to FSO. Try the VBA Name statement:

Name "C:\Test.txt" As "C:\SecondTest.txt"
 
But it deletes from first test File. I was hoping to copy the Test.txt and
then rename it SecondTest.txt

Then I would have two files in the c drive. I would have Text.txt and
secondText.txt

Thanks
 
In that case, use the FileCopy statement:

FileCopy "C:\Test.txt", "C:\SecondTest.txt"
 
But it deletes from first test File. I was hoping to copy the
Test.txt and then rename it SecondTest.txt

Then I would have two files in the c drive. I would have Text.txt
and secondText.txt

Then you *don't* want to RENAME the file at all -- you want to COPY
it.

And, again, there's no need to use outside libraries to do that --
use the VBA FILECOPY statement.
 
Dim fso As New FileSystemObject
fso.CopyFile "C:\temp\Test.txt", "C:\Temp\SecondText.txt"

This is just the most ludicrous suggestion I've seen -- why use an
outside library and add a reference to do something that can be done
with the VBA FILECOPY statement?

Why do people make such stupid suggestions?
 
Why do people make such stupid suggestions?

That was pretty much uncalled for -- I was annoyed at the time, and
shouldn't have posted that.

Apologies to all.
 
Back
Top