+ Reply to Thread
Results 1 to 7 of 7

Possible to change filename using VBA?

  1. #1
    Registered User
    Join Date
    06-09-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    92

    Post Possible to change filename using VBA?

    Hello, is it possible to set a filename using VBA with no user prompt during a Macro?

    For example, like this:

    Please Login or Register  to view this content.
    Any help will be greatly appreciated.

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Possible to change filename using VBA?

    for an open workbook you would have to save the workbook as the new name. for a closed file you can use the Name command.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Possible to change filename using VBA?

    you can rename an open workbook ,i don't know how but asap utilities includes a "rename current file" option which changes the name of the workbook you are currently using so it must be possible!
    ah i see you have to have saved the file first then it can be renamed while open.i supose it needs to know the dir path
    Last edited by martindwilson; 06-15-2012 at 05:22 AM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Possible to change filename using VBA?

    it probably does a saveas and deletes the old file.

  5. #5
    Registered User
    Join Date
    06-09-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    92

    Re: Possible to change filename using VBA?

    That's a bit more than I'm willing to do, is this possible instead?

    In my macro, I have this, which means the file needs to be called Standard.xls or it'll throw an error.
    Please Login or Register  to view this content.
    Is it possible to do this..
    Please Login or Register  to view this content.
    Does this make sense? Sorry for silly syntax, I'm still learning.

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Possible to change filename using VBA?

    use a workbook variable
    Please Login or Register  to view this content.
    if the workbook is the one containing the code, you can just refer to ThisWorkbook instead.

  7. #7
    Registered User
    Join Date
    06-09-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    92

    Re: Possible to change filename using VBA?

    Quote Originally Posted by JosephP View Post
    use a workbook variable
    Please Login or Register  to view this content.
    if the workbook is the one containing the code, you can just refer to ThisWorkbook instead.

    Thank you very much JosephP, and thank you everybody that responded. Consider this solved!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1