+ Reply to Thread
Results 1 to 5 of 5

If Filename exists... then

  1. #1
    Registered User
    Join Date
    09-21-2021
    Location
    Los Angeles
    MS-Off Ver
    365
    Posts
    87

    If Filename exists... then

    Good Afternoon All.

    I currently have the below code being used to save a file

    Please Login or Register  to view this content.
    And would like to update it so that if the filename exists already then to append the name to then be like a "-1", "-2" or something like that... even if only on those files it included the Format(Now(), "yyyy-mm-dd hh-mm-ss") stamp... how would I incorporate this?

  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,510

    Re: If Filename exists... then

    You could use Dir to check for the filename you want to use. If it exists, add the suffix. Loop until it doesn't exist.
    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
    Registered User
    Join Date
    09-21-2021
    Location
    Los Angeles
    MS-Off Ver
    365
    Posts
    87

    Re: If Filename exists... then

    How would I code that?

  4. #4
    Registered User
    Join Date
    09-21-2021
    Location
    Los Angeles
    MS-Off Ver
    365
    Posts
    87

    Re: If Filename exists... then

    I have tried the following code but am running into an issue where it is not seeing the file name exists in the directory.



    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,234

    Re: If Filename exists... then

    eg.
    Please Login or Register  to view this content.
    Artik

+ 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. [SOLVED] VBA code to message box if filename already exists then prevent save
    By Elliott_the_noob in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-14-2018, 02:46 PM
  2. [SOLVED] Generating a PDF file - ask user before overwriting if filename already exists
    By aglawrence in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-15-2018, 01:08 PM
  3. VBA to use cell contents to loop through folder to see if filename exists
    By bdunphy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-14-2013, 11:15 AM
  4. [SOLVED] Find if filename exists and update variable within the filename structure
    By Lungfish in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 03-18-2013, 02:42 AM
  5. [SOLVED] How to: obtain the filename that a module exists in, via VBA?
    By Kevin McCartney in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-02-2005, 06:20 PM
  6. [SOLVED] How to: obtain the filename that a module exists in, via VBA?
    By Kevin McCartney in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-02-2005, 06:17 PM
  7. [SOLVED] Check if filename exists.
    By Darrin Henshaw in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-05-2005, 07:06 PM

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