Private Sub RenameFileUsingName()
Dim oldFileName As String
Dim newFileName As String
' 设置要重命名的源文件和目标文件名
oldFileName = "C:\path\to\your\oldfile.txt"
newFileName = "C:\path\to\your
ewfile.txt"
' 使用 Name 语句重命名文件
On Error GoTo ErrorHandler
Name oldFileName As newFileName
MsgBox "文件重命名成功!"
Exit Sub
ErrorHandler:
MsgBox "文件重命名失败: " & Err.Description
End Sub