#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,814
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,814
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,814
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't rename worksheet Brian Preston Excel Discussion (Misc queries) 1 October 15th 06 03:25 AM
Auto rename and save prompt needed. Gizmo63 Excel Worksheet Functions 0 February 7th 06 02:00 PM
Rename Add-Ins BEEJAY Excel Discussion (Misc queries) 4 December 8th 05 08:18 PM
How to set SAVE AS file name to equal A1 contents when rename file E Excel Discussion (Misc queries) 0 October 19th 05 08:36 PM
How do i auto rename a worksheet to be the same filename as save f Catherine Excel Worksheet Functions 1 December 1st 04 10:17 AM


All times are GMT +1. The time now is 05:57 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"