Results 1 to 8 of 8
  1. #1
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Renaming Files using FileSystemObject (2003)

    No, fileSystemObject doesn't have a method renaming files. You change the Name property of the file. You'd use something like

    Dim fil As Object
    Set fil = fso.GetFile(FileExe)
    fil.Name = Left(fil.Name, Len(fil.Name) - 1)

  2. #2
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Renaming Files using FileSystemObject (2003)

    Thank you very much Hans <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Renaming Files using FileSystemObject (2003)

    While the File system Object does not have a rename method, VBA does have the Name statement that can be used to rename or copy a file.

    Syntax

    Name oldpathname As newpathname
    Regards
    John



  4. #4
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Renaming Files using FileSystemObject (2003)

    That's equally good.
    Thank you very much John. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  5. #5
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Renaming Files using FileSystemObject (2003)

    I'm creating a self-extracting exe file using WinRar but I need to rename it(by removing the final "e" from the extension) so as to be able to send it via Outlook.
    Doesn't the FileSystemObject object have a method for renaming files?
    I was planning on using something like the following:

    ComandoRar = CurrentPath & "winrar.exe a -ep1 -sfx -zc:borgocommento.txt """ & FileExe & """ """ & filePercMdb & """"
    ahtRunAppWait ComandoRar, 0
    MsgBox UCase("Finito")
    If fso.FileExists(FileExe) Then
    FileZipD = Mid(FileExe, 1, Len(FileExe) - 3) & "ex"
    <font color=red>fso.renamefile (FileExe, fileZipD)</font color=red>
    End If

    Attached is the whole subroutine for creating the self-extracting exe file.

  6. #6
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Renaming Files using FileSystemObject (2003)

    How come if you type Name in the VBE editor window and press F1, no specific help for such statement comes up? Only for the Name property.

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Renaming Files using FileSystemObject (2003)

    Try typing name as, selecting it and pressing F1. You'll get a choice of libraries. The VBA one contains the Name instruction.

  8. #8
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Renaming Files using FileSystemObject (2003)

    Thank you Hans,
    I was also thinking that, at the end of the day, you still have to use the Name property of the file to set the oldpathname.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •