Sub RenameFile()
Dim fso As Object
Dim currentPath As String
Dim newPath As String
' 创建 FileSystemObject 对象
Set fso = CreateObject("Scripting.FileSystemObject")
' 设置当前文件路径
currentPath = "C:\Path\To\CurrentFile.xlsx"
' 设置新的文件路径和名称
newPath = "C:\Path\To\NewFile.xlsx"
' 创建文件的副本,并将副本重命名为新的文件名
fso.CopyFile currentPath, newPath
' 释放对象
Set fso = Nothing
End Sub
主要用到,FileSystemObject对象中的CopyFile方法