Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Jul 2001
    Location
    SF, CA
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Save File as Diff. Name Each Time (2000/VBA)

    Hi,

    I have a template file that I do an activeworkbook.save then manually Save As a different name each day in a specific directory. What's the VBA code that allows you to do a Save As with the file name that varies?

    Ex:

    Original File name: Template 2000

    Desired macro: Save As "MM.DD.YYYY.xls" (user inputs file name) in path location.

    Hope this makes sense.

    Thanks!

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Save File as Diff. Name Each Time (2000/VBA)

    You could use something like the following :<pre>Sub FileSave()
    Dim fPath as String, fName as String
    fPath = "C:MyFiles"
    fName = fpath & Format(Now(), "MMDDYYYY HHMM") & ".xls"
    ActiveWorkbook.SaveAs (fname)
    End Sub</pre>

    If you wish to use the date, you may not need user input. The above also includes the time (HHMM) which you may remove if it is not required. I think it is better to omit the periods in the date, as it has a special meaning in filenames.

    You could paste similar code the the Workbook_BeforeSave event if you wished the operation to be transparent and automatic.

    Andrew C

Posting Permissions

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