+ Reply to Thread
Results 1 to 5 of 5

Is it possible to use VBA to name a file without saving it?

  1. #1
    Forum Contributor
    Join Date
    10-03-2015
    Location
    North Carolina, USA
    MS-Off Ver
    Office 365
    Posts
    167

    Is it possible to use VBA to name a file without saving it?

    I currently have code that populates a cell (A1 in a sheet named "File Name"). Is there a way to:

    1.) Use the population of A1 (when my other code executes) as a trigger to name the workbook?
    2.) Not save the workbook to a specific location (just rename it), so that the user can choose where to save it.

    This is for a template that I built that is used by several people. I don't care where they save it, but I do care that everyone follows a consistent naming convention.

    I don't understand how this would be possible, but you guys have amazed me in the past, so I figured I'd give it a shot. Plus, CHAT GPT tells me it is possible, but has not given me correct code to do it yet!

    Thanks

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,646

    Re: Is it possible to use VBA to name a file without saving it?

    Save and SaveAs are the only functions (that I am aware of) that can be used to name a file.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    10-30-2014
    Location
    England
    MS-Off Ver
    2007 / 365
    Posts
    279

    Re: Is it possible to use VBA to name a file without saving it?

    You are going to have to save the file in some way in order to name it.

    One option - You could have your code trigger just a FolderPicker dialog, then concatenate the user selected folder with the filename in the cell, then pass that to SaveCopyAs.

  4. #4
    Forum Contributor
    Join Date
    10-03-2015
    Location
    North Carolina, USA
    MS-Off Ver
    Office 365
    Posts
    167

    Re: Is it possible to use VBA to name a file without saving it?

    Quote Originally Posted by TMS View Post
    Save and SaveAs are the only functions (that I am aware of) that can be used to name a file.
    Quote Originally Posted by EchoPassenger View Post
    You are going to have to save the file in some way in order to name it.

    One option - You could have your code trigger just a FolderPicker dialog, then concatenate the user selected folder with the filename in the cell, then pass that to SaveCopyAs.
    Thank you, both. You have confirmed what I thought. Also, ChatGpt is a liar.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,646

    Re: Is it possible to use VBA to name a file without saving it?

    You're welcome.




    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 02-24-2023, 08:19 AM
  2. Saving a copied selection from Excel file as specifically named CSV file does not work
    By ExcellentVBA in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-14-2022, 07:28 AM
  3. [SOLVED] Saving file seems to combine saving file with Personal.xlsb
    By taylorsm in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-24-2017, 04:48 PM
  4. Replies: 0
    Last Post: 06-15-2016, 06:24 PM
  5. Replies: 11
    Last Post: 08-23-2014, 01:28 PM
  6. Problem saving Excel file that copies an embedded object from a separate file
    By bhodge10 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-16-2012, 02:47 PM
  7. Creating a .txt file extracting information from a Excel file saving as .resx file
    By AbdallahHajbed in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-19-2012, 09:00 AM

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