ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   saving new file name (https://www.excelbanter.com/excel-programming/285440-saving-new-file-name.html)

douvid

saving new file name
 
Hi ,
I need to save an open file under a new name by replacing the old one.
The problem is that the new name is generated by the content of the file, I mean that the file is open.
Does someone has a good idea.

cheers,
Douvid


Nikos Yannacopoulos[_5_]

saving new file name
 
Douvid,

You need to write some VB code in a macro for this. In
short, your code should:

1.get the old name file before you save under the new name:
oldname = activeworkbook.path & "/" & _
activeworkbook.name
2.save under the new name
activeworkbook.saveas "TheNewFilename.xls"
same folder, or full path for different folder). The new
file name will most likely be a variable whose value is
read from the spreadsheet, I guess (in that case omit the
quotes).
3. delete original file
kill oldname

HTH,
Nikos
-----Original Message-----
Hi ,
I need to save an open file under a new name by replacing

the old one.
The problem is that the new name is generated by the

content of the file, I mean that the file is open.
Does someone has a good idea.

cheers,
Douvid

.


BrianB

saving new file name
 
Is this what you want ? (will need to be adapted. might need full path)

'==================================
Sub UnTested()
Dim OldName As String
Dim NewName As String
OldName = ActiveWorkbook.Name
NewName = Worksheets("Sheet1").Value
'- make new file
ActiveWorkbook.SaveAs FileName:=NewName
'- delete old file
Kill OldName
End Sub
'==============================================


Regards
BrianB
-------------------------------------



Douvid wrote in message ...
Hi ,
I need to save an open file under a new name by replacing the old one.
The problem is that the new name is generated by the content of the file, I mean that the file is open.
Does someone has a good idea.

cheers,
Douvid



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

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