'Rename opened workbook without firstly close it?
If I want to rename an opened workbook, I need to close it firstly, and then rename it which is a little tedious.
on 3rd party software “Office Tab” , It has this feature to Rename opened workbook without firstly close it.
Is it possible to be done by Excel without using other software ,even by using VBA soultion.
In advance , greatful for any help.
Solution 1:[1]
there are various solutions to this problem,
the first one will be to run the following:
ActiveWorkbook.SaveAs "MyFile.xls"
Kill "MyPreviousFileName.xls"
you do have to save it in order to change its name. and if you want to save the old copy, you can remove the kill function
if you want it to be more precise you can do as follows (edit: added @funthomas's suggestion):
Sub Macro2()
Dim rootDir as string
Dim FileName as String
rootDir = "\Desktop"
rootDir = Replace(rootDir, "@1", environ(UserProfile))
FileName = "Test"
ActiveWorkbook.SaveAs rootDir & FileName & ".xlsm"
End Sub
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
