+ Reply to Thread
Results 1 to 13 of 13

Code to create a custom .csv filename with version stamp in filename

  1. #1
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    457

    Code to create a custom .csv filename with version stamp in filename

    Hi All,

    I've been struggling to write some code to create a .csv file with an updating version stamp filename.

    I have an original excel file which i use to do formulas in but need to create a .csv file from this data which will be used to load into some financial software.

    Every month i will be resaving the primary excel file in the latest monthly folder and manually update the filename (Adj - Jun12, Adj - Jul12, etc.) but i would like to run a .csv file to save in the same location as the primary excel file and give it a version stamp in the filename automatically.

    Example below.


    Adj - Jun12 (main excel file)
    to create .csv file with name: Adj_v1_JUN-2012 (first run)
    to create .csv file with name: Adj_v2_JUN-2012 second run, etc.

    hope this makes sense.

    TIA
    Neill
    Last edited by Gti182; 07-05-2012 at 10:19 AM. Reason: not solved

  2. #2
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Code to create a custom .csv filename with version stamp in filename

    Do you currently save the csv file programmtically or manually? If the former then you can save the current version number to a second worksheet and use that or use filesystem object to detect if the file already exist and then adjust accordingly. If you are doing it manually then we should be able to whip something up for you.
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Code to create a custom .csv filename with version stamp in filename

    Hello Gti182,

    Do you mean you want to increment the version name whenever the csv file is saved from Excel?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    457

    Re: Code to create a custom .csv filename with version stamp in filename

    I'm doing it all manually at the minute.

    @Leith Ross: Yes Each .csv file saved needs to be saved in numerical order i.e. v1, v2, v3 etc

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Code to create a custom .csv filename with version stamp in filename

    Hello Gti182,

    This macro will save the current workbook as a csv file with the appropriate version number. The next question is how should we trigger the macro?
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    457

    Re: Code to create a custom .csv filename with version stamp in filename

    Thanks Leith that works a treat! I see it renames the original excel file though, is there a way to keep the filename the same as before?

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Code to create a custom .csv filename with version stamp in filename

    Hello Gti182,

    This will not rename the original workbook. Since this is a CSV file, Excel will only save the Active Sheet as the CSV file.
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    457

    Re: Code to create a custom .csv filename with version stamp in filename

    awesome, got it to work perfectly. Thanks for the quick code, u a machine!

  9. #9
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    457

    Re: Code to create a custom .csv filename with version stamp in filename

    Hi All,

    I'm not sure what happened with my code but all was working fine before i added some code to change formatting

    The macro runs through fine but it saves the csv file to my desktop and not the original save location of the excel producing the csv file?

    Can anyone see where i'm going wrong?


    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    457

    Re: Code to create a custom .csv filename with version stamp in filename

    anyone?

  11. #11
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    457

    Re: Code to create a custom .csv filename with version stamp in filename

    gaaah this is driving me mad! Why is the csv file saving to my desktop???? grrrrr

    I'll do some more fiddling...

  12. #12
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    457

    Re: Code to create a custom .csv filename with version stamp in filename

    to the top, still no luck

  13. #13
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    457

    Re: Code to create a custom .csv filename with version stamp in filename

    bump bump

+ 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