FileSystemObject Remane file


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
 
Ad

Advertisements

D

Douglas J. Steele

No need to resort to FSO. Try the VBA Name statement:

Name "C:\Test.txt" As "C:\SecondTest.txt"
 
G

Guest

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
 
G

Guest

Dim fso As New FileSystemObject
fso.CopyFile "C:\temp\Test.txt", "C:\Temp\SecondText.txt"
 
D

Douglas J. Steele

In that case, use the FileCopy statement:

FileCopy "C:\Test.txt", "C:\SecondTest.txt"
 
D

David W. Fenton

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.
 
Ad

Advertisements

D

David W. Fenton

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?
 
Ad

Advertisements

D

David W. Fenton

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.
 

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

Similar Threads

FileSystemObject 2
FileSystemObject 2
FileSystemObject 5
FileSystemObject 2
FileSystemObject 1
FileSystemObject No LongName 1
FileSystemObject drive error 4
Question re FileSystemObject 2

Top