Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Save and rename
I often want to save a workbook and rename it and wonder if there's a single
step solution. I know I can do a save and then go into the windows explorer and rename the workbook. Or I can do a save as and then go to windows explorer and delete the previous version. It would be nice if there was a way to do it all within excel in a single step. |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Save and rename
Only by using code to save as a different name then deleting the original.
What name would you like to "Save As"? Is there a value in a cell or somesuch? Gord Dibben MS Excel MVP On Wed, 25 Feb 2009 13:14:34 -0800, Steve wrote: I often want to save a workbook and rename it and wonder if there's a single step solution. I know I can do a save and then go into the windows explorer and rename the workbook. Or I can do a save as and then go to windows explorer and delete the previous version. It would be nice if there was a way to do it all within excel in a single step. |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Save and rename
There's a myriad of situations that might occur. But a common one is where
I've been working on a workbook and want to better describe what I've done that day or week. For example I may want to add to the end of the filename something like "upd 2-25-09 w_actuals". Or I started doing something for NJ and added NY so want to change 2008 NJ to 2008 NJ_NY. It's really so often that I want to do this but it's always to give a better description of what the workbook contains without having to sort through a bunch of different versions and then having to delete them later. "Gord Dibben" wrote: Only by using code to save as a different name then deleting the original. What name would you like to "Save As"? Is there a value in a cell or somesuch? Gord Dibben MS Excel MVP On Wed, 25 Feb 2009 13:14:34 -0800, Steve wrote: I often want to save a workbook and rename it and wonder if there's a single step solution. I know I can do a save and then go into the windows explorer and rename the workbook. Or I can do a save as and then go to windows explorer and delete the previous version. It would be nice if there was a way to do it all within excel in a single step. |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Save and rename
Stick this macro into your Personal.xls
Run it on your current open workbook. It will pop up the saveas dialog where you enter a name. The workbook will be saved as that name and original killed(deleted) from your Computer. Sub saveas_kill() Dim oldname As String oldname = ActiveWorkbook.Name Set NewBook = Workbooks.Add fName = Application.GetSaveAsFilename NewBook.saveas Filename:=fName & "xls" Workbooks(oldname).Close Kill oldname End Sub Gord On Wed, 25 Feb 2009 14:14:01 -0800, Steve wrote: There's a myriad of situations that might occur. But a common one is where I've been working on a workbook and want to better describe what I've done that day or week. For example I may want to add to the end of the filename something like "upd 2-25-09 w_actuals". Or I started doing something for NJ and added NY so want to change 2008 NJ to 2008 NJ_NY. It's really so often that I want to do this but it's always to give a better description of what the workbook contains without having to sort through a bunch of different versions and then having to delete them later. "Gord Dibben" wrote: Only by using code to save as a different name then deleting the original. What name would you like to "Save As"? Is there a value in a cell or somesuch? Gord Dibben MS Excel MVP On Wed, 25 Feb 2009 13:14:34 -0800, Steve wrote: I often want to save a workbook and rename it and wonder if there's a single step solution. I know I can do a save and then go into the windows explorer and rename the workbook. Or I can do a save as and then go to windows explorer and delete the previous version. It would be nice if there was a way to do it all within excel in a single step. |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
Save and rename
Hope you didn't run that stupid macro on a non-backed up file.
Try this effort which copies the original before killing it!! Note: if newname already exists you will asked to overwrite or not. Sub Saveas_Kill() Dim oldname As String oldname = ActiveWorkbook.Name newname = InputBox("Enter a Name") ActiveWorkbook.SaveCopyAs Filename:=newname & ".xls" Workbooks(oldname).Close Kill oldname End Sub Gord On Wed, 25 Feb 2009 15:26:27 -0800, Gord Dibben <gorddibbATshawDOTca wrote: Stick this macro into your Personal.xls Run it on your current open workbook. It will pop up the saveas dialog where you enter a name. The workbook will be saved as that name and original killed(deleted) from your Computer. Sub saveas_kill() Dim oldname As String oldname = ActiveWorkbook.Name Set NewBook = Workbooks.Add fName = Application.GetSaveAsFilename NewBook.saveas Filename:=fName & "xls" Workbooks(oldname).Close Kill oldname End Sub Gord On Wed, 25 Feb 2009 14:14:01 -0800, Steve wrote: There's a myriad of situations that might occur. But a common one is where I've been working on a workbook and want to better describe what I've done that day or week. For example I may want to add to the end of the filename something like "upd 2-25-09 w_actuals". Or I started doing something for NJ and added NY so want to change 2008 NJ to 2008 NJ_NY. It's really so often that I want to do this but it's always to give a better description of what the workbook contains without having to sort through a bunch of different versions and then having to delete them later. "Gord Dibben" wrote: Only by using code to save as a different name then deleting the original. What name would you like to "Save As"? Is there a value in a cell or somesuch? Gord Dibben MS Excel MVP On Wed, 25 Feb 2009 13:14:34 -0800, Steve wrote: I often want to save a workbook and rename it and wonder if there's a single step solution. I know I can do a save and then go into the windows explorer and rename the workbook. Or I can do a save as and then go to windows explorer and delete the previous version. It would be nice if there was a way to do it all within excel in a single step. |
#6
Posted to microsoft.public.excel.misc
|
|||
|
|||
Save and rename
Thank you for the reply. The code seems to create a new blank workbook and
saves that which isn't exactly what I wanted. I tweaked your code slightly and came up with this. It seems to work. Am I on the right track? Sub saveas_kill() Dim oldname As String oldname = ActiveWorkbook.Name fName = Application.GetSaveAsFilename ActiveWorkbook.SaveAs Filename:=fName & "xls" Kill oldname End Sub "Gord Dibben" wrote: Stick this macro into your Personal.xls Run it on your current open workbook. It will pop up the saveas dialog where you enter a name. The workbook will be saved as that name and original killed(deleted) from your Computer. Sub saveas_kill() Dim oldname As String oldname = ActiveWorkbook.Name Set NewBook = Workbooks.Add fName = Application.GetSaveAsFilename NewBook.saveas Filename:=fName & "xls" Workbooks(oldname).Close Kill oldname End Sub Gord On Wed, 25 Feb 2009 14:14:01 -0800, Steve wrote: There's a myriad of situations that might occur. But a common one is where I've been working on a workbook and want to better describe what I've done that day or week. For example I may want to add to the end of the filename something like "upd 2-25-09 w_actuals". Or I started doing something for NJ and added NY so want to change 2008 NJ to 2008 NJ_NY. It's really so often that I want to do this but it's always to give a better description of what the workbook contains without having to sort through a bunch of different versions and then having to delete them later. "Gord Dibben" wrote: Only by using code to save as a different name then deleting the original. What name would you like to "Save As"? Is there a value in a cell or somesuch? Gord Dibben MS Excel MVP On Wed, 25 Feb 2009 13:14:34 -0800, Steve wrote: I often want to save a workbook and rename it and wonder if there's a single step solution. I know I can do a save and then go into the windows explorer and rename the workbook. Or I can do a save as and then go to windows explorer and delete the previous version. It would be nice if there was a way to do it all within excel in a single step. |
#7
Posted to microsoft.public.excel.misc
|
|||
|
|||
Save and rename
Steve
The original code I posted was not good as you found out. Brain-fart by me. Yes, you are on the right track with your revision. See my yesterday's correction posting in this thread for another shot at it. If you don't see that posting here is the code with an inputbox for entering a new name instead of pulling up the save as dialog. Note: if newname already exists you will asked to overwrite or not. Sub Saveas_Kill() Dim oldname As String oldname = ActiveWorkbook.Name newname = InputBox("Enter a Name") ActiveWorkbook.SaveCopyAs Filename:=newname & ".xls" Workbooks(oldname).Close Kill oldname End Sub Gord On Thu, 26 Feb 2009 06:56:07 -0800, Steve wrote: Thank you for the reply. The code seems to create a new blank workbook and saves that which isn't exactly what I wanted. I tweaked your code slightly and came up with this. It seems to work. Am I on the right track? Sub saveas_kill() Dim oldname As String oldname = ActiveWorkbook.Name fName = Application.GetSaveAsFilename ActiveWorkbook.SaveAs Filename:=fName & "xls" Kill oldname End Sub "Gord Dibben" wrote: Stick this macro into your Personal.xls Run it on your current open workbook. It will pop up the saveas dialog where you enter a name. The workbook will be saved as that name and original killed(deleted) from your Computer. Sub saveas_kill() Dim oldname As String oldname = ActiveWorkbook.Name Set NewBook = Workbooks.Add fName = Application.GetSaveAsFilename NewBook.saveas Filename:=fName & "xls" Workbooks(oldname).Close Kill oldname End Sub Gord On Wed, 25 Feb 2009 14:14:01 -0800, Steve wrote: There's a myriad of situations that might occur. But a common one is where I've been working on a workbook and want to better describe what I've done that day or week. For example I may want to add to the end of the filename something like "upd 2-25-09 w_actuals". Or I started doing something for NJ and added NY so want to change 2008 NJ to 2008 NJ_NY. It's really so often that I want to do this but it's always to give a better description of what the workbook contains without having to sort through a bunch of different versions and then having to delete them later. "Gord Dibben" wrote: Only by using code to save as a different name then deleting the original. What name would you like to "Save As"? Is there a value in a cell or somesuch? Gord Dibben MS Excel MVP On Wed, 25 Feb 2009 13:14:34 -0800, Steve wrote: I often want to save a workbook and rename it and wonder if there's a single step solution. I know I can do a save and then go into the windows explorer and rename the workbook. Or I can do a save as and then go to windows explorer and delete the previous version. It would be nice if there was a way to do it all within excel in a single step. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can't rename worksheet | Excel Discussion (Misc queries) | |||
Auto rename and save prompt needed. | Excel Worksheet Functions | |||
Rename Add-Ins | Excel Discussion (Misc queries) | |||
How to set SAVE AS file name to equal A1 contents when rename file | Excel Discussion (Misc queries) | |||
How do i auto rename a worksheet to be the same filename as save f | Excel Worksheet Functions |