Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
What I would like is a macro that onclosing my workbook asks for a date to be
entered by means of an inputbox in ddmmyy format and then automatically saves the workbook as C:\docs\"form-ddmmyy". Any help would be greatly appreciated. -- Al |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
This might not be what you are looking for but try it and let me know
Copy and paste this into the ThisWorkbook module Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim fname As Variant Dim Wb As Workbook Set Wb = ActiveWorkbook Again: fname = Application.GetSaveAsFilename(Format(Now(), "[$-409]mmddyy;@"), _ fileFilter:="Excel Files (*.xls), *.xls") If fname = False Then Exit Sub If Dir(fname) < "" Then MsgBox "File name already exist select a new name", vbOKOnly If Dir(fname) < "" Then GoTo Again Wb.SaveCopyAs fname End Sub "gramps" wrote: What I would like is a macro that onclosing my workbook asks for a date to be entered by means of an inputbox in ddmmyy format and then automatically saves the workbook as C:\docs\"form-ddmmyy". Any help would be greatly appreciated. -- Al |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Thanks Mike but it is not quite what I'm after. What I need is a macro that
when the workbook is closed it opens an input box which asks you to enter a date. When this is entered it becomes part of the filename and so the path that is created and saved as C:\docs\report-ddmmyy. This same report is saved on a daily basis and is therefore distinguihed by the new date. Thanks again -- Al "Mike" wrote: This might not be what you are looking for but try it and let me know Copy and paste this into the ThisWorkbook module Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim fname As Variant Dim Wb As Workbook Set Wb = ActiveWorkbook Again: fname = Application.GetSaveAsFilename(Format(Now(), "[$-409]mmddyy;@"), _ fileFilter:="Excel Files (*.xls), *.xls") If fname = False Then Exit Sub If Dir(fname) < "" Then MsgBox "File name already exist select a new name", vbOKOnly If Dir(fname) < "" Then GoTo Again Wb.SaveCopyAs fname End Sub "gramps" wrote: What I would like is a macro that onclosing my workbook asks for a date to be entered by means of an inputbox in ddmmyy format and then automatically saves the workbook as C:\docs\"form-ddmmyy". Any help would be greatly appreciated. -- Al |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel Automatic Calculation Options will not Save | Setting up and Configuration of Excel | |||
Automatic Save and Exit | Excel Discussion (Misc queries) | |||
Automatic save workbook | Excel Worksheet Functions | |||
How do I set interval for automatic save? (not auto recovery) | Excel Discussion (Misc queries) | |||
How do you turn off automatic "save a copy" in Excel | Excel Discussion (Misc queries) |