Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default set excel <filename to <filename-date

I would like to have the filename of a excel WB set to
<filename-currentdate on open the original file so when
the people save it, it will save it to the new name. ie:

open MGA (template file) and make the active WB
MGA-071106 would be a copy of MGA.xls. That way when
the people click Save, it will save it to the correct new file (they
have problems following simple instructions).

Thanks...



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default set excel <filename to <filename-date

Bob,
There is the Workbook_BeforeSave event. This will update the file name each
day, if it is subsequently saved on a later day, which may not be what you
want, but ...

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Dim strFileName As String
strFileName = "MGA-" & Format(Date, "mmddyy") & ".xls"
Application.EnableEvents = False
With ThisWorkbook
If .Name = strFileName Then
.Save
Else
.SaveAs "MGA-" & Format(Date, "mmddyy") & ".xls"
End If
End With
Application.EnableEvents = True
Cancel = True
End Sub

You may also need to deal with the situation if there is already a file with
this name present.

NickHK

"bob engler" wrote in message
...
I would like to have the filename of a excel WB set to
<filename-currentdate on open the original file so when
the people save it, it will save it to the new name. ie:

open MGA (template file) and make the active WB
MGA-071106 would be a copy of MGA.xls. That way when
the people click Save, it will save it to the correct new file (they
have problems following simple instructions).

Thanks...





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default set excel <filename to <filename-date

Hi Bob,

copy the following code to the module of your workbook. This will add
the date to your workbook name and save the workbook on opening it.

Private Sub Workbook_Open()
ThisWorkbook.SaveAs Filename:=Left(ThisWorkbook.FullName, _
Len(ThisWorkbook.FullName) - 4) & "-" & Format(Date, "mmddyy") & ".xls"
End Sub

Regards,
Ingolf

bob engler schrieb:

I would like to have the filename of a excel WB set to
<filename-currentdate on open the original file so when
the people save it, it will save it to the new name. ie:

open MGA (template file) and make the active WB
MGA-071106 would be a copy of MGA.xls. That way when
the people click Save, it will save it to the correct new file (they
have problems following simple instructions).

Thanks...


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cell("filename") doesn't update to new filename when do save as. Louis Excel Worksheet Functions 2 March 22nd 07 07:27 PM
set filename to <filename-date on open bob engler Excel Worksheet Functions 2 July 13th 06 05:11 AM
date in filename JCanyoneer Excel Programming 1 April 5th 05 12:08 AM
Automatically saving an Excel spreadsheet with today's date in the filename Ian M Excel Programming 2 April 30th 04 01:09 AM
Saving filename same as import filename Matt Excel Programming 4 February 24th 04 03:01 PM


All times are GMT +1. The time now is 10:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"