ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Save and rename (https://www.excelbanter.com/excel-discussion-misc-queries/222305-save-rename.html)

Steve

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.

Gord Dibben

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.



Steve

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.




Gord Dibben

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.





Steve

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.





Gord Dibben

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.




Gord Dibben

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.







All times are GMT +1. The time now is 04:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com