Let's say I need to rename a workbook on my desktop with the name Test.xlsm to Test2.xlsm in the same location.
I may rename it as follows by using the Name statement:
Sub Rename_using_Name()
Dim oldName As String, newName As String
oldName = "D:\Users\UserName\Desktop\Test.xlsm"
newName = "D:\Users\UserName\Desktop\Test2.xlsm"
Name oldName As newName
End Sub
Or, I can rename using FileSystemObject , like the following:
Sub Rename_using_FileSystemObject()
Dim fso As Object, oldName As String, newName As String
Set fso = CreateObject("Scripting.FileSystemObject")
oldName = "D:\Users\UserName\Desktop\Test.xlsm"
newName = "D:\Users\UserName\Desktop\Test2.xlsm"
fso.MoveFile oldName, newName
End Sub
I seek for any additional means to rename a workbook other than the above-cited ones.
In advance, great thanks for all your help.