Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I want to save a file as its original filename with today's date applied to
the end of the filename. For example: filename = budget.xls I open, make changes, etc., click macro button. File is saved as budget_5-7-2007.xls Can someone help me do this? I wan the same directory location as the original file to be used when saving. thanks, jkt |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Maybe something like this would work for you... But note that if your
original file name would have an underscore character, you might run into problems.. Sub jkt() Dim iPos As Integer With ThisWorkbook iPos = InStrRev(.Name, "_") If iPos = 0 Then .SaveAs .Path & "\" & Replace(.Name, ".XLS", "_" & Format(Now, "m-d-yyyy") & ".xls", 1, -1, vbTextCompare) Else .SaveAs .Path & "\" & Left(.Name, iPos) & Format(Now, "m-d-yyyy") & ".xls" End If End With End Sub -- Hope that helps. Vergel Adriano "jkt" wrote: I want to save a file as its original filename with today's date applied to the end of the filename. For example: filename = budget.xls I open, make changes, etc., click macro button. File is saved as budget_5-7-2007.xls Can someone help me do this? I wan the same directory location as the original file to be used when saving. thanks, jkt |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi jkt,
You might have duplication file unless you delete it after you saveas... you can try this one: Sub SaveAsDate() Dim Wbk As Workbook, Addr As String Set Wbk = Workbooks("ABC.xls") Addr = Wbk.FullName 'need variable to delete file Wbk.SaveAs Replace(.Name, ".xls", "") & "_" & _ Format$(Now, "m-d-yyyy") & ".xls" Kill Addr End Sub -- Regards, Halim "jkt" wrote: I want to save a file as its original filename with today's date applied to the end of the filename. For example: filename = budget.xls I open, make changes, etc., click macro button. File is saved as budget_5-7-2007.xls Can someone help me do this? I wan the same directory location as the original file to be used when saving. thanks, jkt |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel 2007 Changes date stamp on Save As | Excel Discussion (Misc queries) | |||
How can you save a spreadsheet with a date stamp. | Excel Worksheet Functions | |||
Save File with Date and Time Stamp | Excel Programming | |||
Save file with time date stamp | Excel Programming | |||
Date Stamp Save | Excel Programming |