Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    416
    Thanks
    0
    Thanked 0 Times in 0 Posts

    rename a file in a macro (All)

    Hi

    Is it possible to rename a WORD document in a macro? BTW: I searched the forum but can't find anything useful under rename a file, renaming a file etc.

    I know, I can save the document with another name and then delete the original document but I would like to preseve the date/time. Basically I am creating a backup of document before manipulating it further.

    Thanks

    Robie.
    Thanks.
    Robie

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: rename a file in a macro (All)

    You can rename a file on disk, but I don't think you can rename an open file. So the file can't rename itself. Maybe you can describe the desired scenario in a bit more detail.

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

    Re: rename a file in a macro (All)

    As Jefferson indicated, you cannot rename the currently open document. You can rename a document (or any other file that is not in use) as follows:

    Dim strPath As String
    Dim strOldName As String
    Dim strNewName As String

    strPath = "C:Word"
    strOldName = "OriginalName.doc"
    strNewName = "ChangedName.doc"

    Name strPath & strOldName As strPath & strNewName

    This will rename a file named OriginalName.doc in the folder C:Word to ChangedName.doc.

  4. #4
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Wellington, New Zealand
    Posts
    143
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: rename a file in a macro (All)

    In Windows Explorer you can copy an open Word document and paste it into the same location, and it prefixes "Copy of " to the file name and preserves the last "Modified" date, but I've no idea how you'd do that via a Word macro. (I'm using Windows 2000, SP4.)

  5. #5
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    416
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: rename a file in a macro (All)

    Wow. Thanks you all. Much obliged. Just what I wanted to know. Very grateful to you guys for the help.
    Thanks.
    Robie

Posting Permissions

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