FileSystemObject Remane file

Discussion in 'Microsoft Access VBA Modules' started by Guest, Jul 16, 2007.

  1. Guest

    Guest 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
    Guest, Jul 16, 2007
    1. Advertisements

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

    Name "C:\Test.txt" As "C:\SecondTest.txt"
    Douglas J. Steele, Jul 16, 2007
    1. Advertisements

  3. Guest

    Guest 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

    Guest, Jul 16, 2007
  4. Guest

    Guest Guest

    Dim fso As New FileSystemObject
    fso.CopyFile "C:\temp\Test.txt", "C:\Temp\SecondText.txt"
    Guest, Jul 16, 2007
  5. In that case, use the FileCopy statement:

    FileCopy "C:\Test.txt", "C:\SecondTest.txt"
    Douglas J. Steele, Jul 17, 2007
  6. Then you *don't* want to RENAME the file at all -- you want to COPY

    And, again, there's no need to use outside libraries to do that --
    use the VBA FILECOPY statement.
    David W. Fenton, Jul 17, 2007
  7. 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?
    David W. Fenton, Jul 17, 2007
  8. That was pretty much uncalled for -- I was annoyed at the time, and
    shouldn't have posted that.

    Apologies to all.
    David W. Fenton, Jul 17, 2007
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.