Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
How can I create a code in VBA, in Excel 2007, for when closing a book, save it automatically with a new name (the system date and time)? Thanks -- HC |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In the This Workbook Module;
"lena_form" wrote in message ... Hello, How can I create a code in VBA, in Excel 2007, for when closing a book, save it automatically with a new name (the system date and time)? Thanks -- HC |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In the ThisWorkbook Module;
Private Sub Workbook_BeforeClose(Cancel As Boolean) Me.SaveAs Me.Path & "\" & Format(Now, "hh:mm-mm-dd-yyyy") End Sub -- Regards Dave Hawley www.ozgrid.com "lena_form" wrote in message ... Hello, How can I create a code in VBA, in Excel 2007, for when closing a book, save it automatically with a new name (the system date and time)? Thanks -- HC |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hmm,
I wouldn't use this formatting, because the default sorting order is by name, which would sort the files like 06:35-04-27-2010 09:17-04-20-2010 09:25-01-01-2009 10:12-04-27-2010 I would use Format(Now, "yyyy-mm-dd-hh:nn:ss") BTW, using "mm" for both minutes and months is ambiguous and may cause problems. "nn" is always interpreted as minutes. HTH. Helmut "ozgrid.com" schrieb im Newsbeitrag ... In the ThisWorkbook Module; Private Sub Workbook_BeforeClose(Cancel As Boolean) Me.SaveAs Me.Path & "\" & Format(Now, "hh:mm-mm-dd-yyyy") End Sub -- Regards Dave Hawley www.ozgrid.com "lena_form" wrote in message ... Hello, How can I create a code in VBA, in Excel 2007, for when closing a book, save it automatically with a new name (the system date and time)? Thanks -- HC |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Apr 28, 2:40*pm, "Helmut Meukel" wrote:
Hmm, I wouldn't use this formatting, because the default sorting order is by name, which would sort the files like 06:35-04-27-2010 09:17-04-20-2010 09:25-01-01-2009 10:12-04-27-2010 I would use Format(Now, "yyyy-mm-dd-hh:nn:ss") BTW, using "mm" for both minutes and months is ambiguous and may cause problems. "nn" is always interpreted as minutes. HTH. Helmut "ozgrid.com" schrieb im ... In the ThisWorkbook Module; Private Sub Workbook_BeforeClose(Cancel As Boolean) * *Me.SaveAs Me.Path & "\" & Format(Now, "hh:mm-mm-dd-yyyy") End Sub -- Regards Dave Hawley www.ozgrid.com "lena_form" wrote in message ... Hello, How can I create a code in VBA, in Excel 2007, for when closing a book, save it automatically with a new name (the system date and time)? Thanks -- HC- Hide quoted text - - Show quoted text - the above will save the file without extension.Which should be avoided. the correct code is if 2003 then Me.SaveAs Me.Path & "\" & Format(Now, "hh:mm-mm-dd-yyyy") & ".xls" if 2007 then Me.SaveAs Me.Path & "\" & Format(Now, "hh:mm-mm-dd-yyyy") & ".xlsx" |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The Format was an example, nothing more. The end user can change it to suit.
-- Regards Dave Hawley www.ozgrid.com "Helmut Meukel" wrote in message ... Hmm, I wouldn't use this formatting, because the default sorting order is by name, which would sort the files like 06:35-04-27-2010 09:17-04-20-2010 09:25-01-01-2009 10:12-04-27-2010 I would use Format(Now, "yyyy-mm-dd-hh:nn:ss") BTW, using "mm" for both minutes and months is ambiguous and may cause problems. "nn" is always interpreted as minutes. HTH. Helmut "ozgrid.com" schrieb im Newsbeitrag ... In the ThisWorkbook Module; Private Sub Workbook_BeforeClose(Cancel As Boolean) Me.SaveAs Me.Path & "\" & Format(Now, "hh:mm-mm-dd-yyyy") End Sub -- Regards Dave Hawley www.ozgrid.com "lena_form" wrote in message ... Hello, How can I create a code in VBA, in Excel 2007, for when closing a book, save it automatically with a new name (the system date and time)? Thanks -- HC |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I hope you are looking to save a copy of the workbook to the same path with
the date/time... Private Sub Workbook_BeforeClose(Cancel As Boolean) Application.DisplayAlerts = False Me.SaveCopyAs Me.Path & "\" & Format(Now, "yyyymmdd-hhmmss") & ".xls" Application.DisplayAlerts = True End Sub -- Jacob (MVP - Excel) "lena_form" wrote: Hello, How can I create a code in VBA, in Excel 2007, for when closing a book, save it automatically with a new name (the system date and time)? Thanks -- HC |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Suddenly Save and Save as greyed out in Excel 2003 | Excel Discussion (Misc queries) | |||
Save, save as, page setup dimmed out in unprotected excel sheet? | Excel Discussion (Misc queries) | |||
'document not saved' for 'save' or 'save as' an EXCEL file | Excel Discussion (Misc queries) | |||
Save Excel file - prompts to save - no Volitile functions used | Excel Worksheet Functions | |||
save button in excel to save one of the worksheets with a cell value as its name | Excel Programming |