+ Reply to Thread
Results 1 to 3 of 3

Check if file exists and if so save file incremented by 1 e.g. filename(1).xlsm

  1. #1
    Registered User
    Join Date
    07-27-2012
    Location
    Sydney Aust
    MS-Off Ver
    Excel 2010
    Posts
    92

    Check if file exists and if so save file incremented by 1 e.g. filename(1).xlsm

    I have a spreadsheet. I export data from the spreadsheet into a newly created word doc. then i save that word doc in a designated folder.. All this done with a macro within excel.


    The issue i have is that sometimes the file name is the same as previously used, so i would like to put a check in there to see if the file already exists and if it does then add a suffix (like how windows does it) e.g. (1) or (2)


    this is part of the code I am using


    Please Login or Register  to view this content.

    This is the part that does the overwriting

    Please Login or Register  to view this content.

    laymans terms of the code I need help with
    Please Login or Register  to view this content.
    How do i make sure that it is not the same as a previously created file? e.g. "(1)"


    Thanks for your help

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Check if file exists and if so save file incremented by 1 e.g. filename(1).xlsm

    Try this. It will number the file names until one number is not used.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    07-27-2012
    Location
    Sydney Aust
    MS-Off Ver
    Excel 2010
    Posts
    92

    Re: Check if file exists and if so save file incremented by 1 e.g. filename(1).xlsm

    Alpha frog

    Thanks a heap. You have fixed my issue and I really appreciate it. I can understand the code and will us it in the future.

    Thanks again

+ 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: 1
    Last Post: 12-14-2013, 04:28 AM
  2. Replies: 3
    Last Post: 05-21-2013, 08:22 AM
  3. Save file xls file as xlsm - macro won't run in xlsm workbook
    By captbluefin in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-07-2012, 11:39 AM
  4. Incremented File Save Names
    By ScotyB in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-09-2010, 03:25 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