Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Move one ws to new wb. Save new Wb with same but modified name as original WB

Greetings:
Looking to name a new WB with the (modified) name of the original WB.

The following code MOVES one worksheet to a new WB.
' MOVE "COM.CALC to NEW WorkBook
Sheets("COM.CALC.").Move

At this point the new WB is the active one.
I'm looking to get the (previously saved) file name from the original file,
and use it on the new file, with "-CC" added to the end.
The original file name will always be different. (its not a template with a
"fixed" name)
The path for the new WB always to be the same.
So new file to save as: C:\CONTRACTS COMMISH\OldFileName-CC.
Then the old file is to be closed without a save.

Thanks all in advance.....................


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Move one ws to new wb. Save new Wb with same but modified name as

This has not been tested.

Assuming that the procedure is in the original workbook's code module:
Sub moveSheet()
Dim myPath As String, wbNewName As String
myPath = ThisWorkbook.Path
wbNewName = ThisWorkbook.Name & "my suffix"
Sheets("COM.CALC.").Move 'Not sure about the period after CALC
ActiveWorkbook.SaveAs FileName:=myPath & "\" & wbNewName
End Sub


"BEEJAY" wrote:

Greetings:
Looking to name a new WB with the (modified) name of the original WB.

The following code MOVES one worksheet to a new WB.
' MOVE "COM.CALC to NEW WorkBook
Sheets("COM.CALC.").Move

At this point the new WB is the active one.
I'm looking to get the (previously saved) file name from the original file,
and use it on the new file, with "-CC" added to the end.
The original file name will always be different. (its not a template with a
"fixed" name)
The path for the new WB always to be the same.
So new file to save as: C:\CONTRACTS COMMISH\OldFileName-CC.
Then the old file is to be closed without a save.

Thanks all in advance.....................



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
'Trick' to restore original sort order after data modified? L Welker Excel Discussion (Misc queries) 4 April 3rd 23 04:17 PM
Original cell formatting clears when I move contents LarryN Excel Discussion (Misc queries) 2 April 9th 08 10:54 PM
Auto save replaced my original file and now I need the original? Hols Excel Discussion (Misc queries) 1 August 15th 05 10:34 PM
save a doument that has not been modified Alan Excel Discussion (Misc queries) 2 July 7th 05 11:09 AM
How to get the original data in a cell after it is modified Raghunandan Excel Programming 4 August 11th 04 08:03 AM


All times are GMT +1. The time now is 03:49 PM.

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"