Sub 重命名文件或者文件夹()
Dim sourctfile As String
Dim destinationfile As String
Dim spath As String
SourceFile = Application.InputBox(prompt:="请输入需要重命名文件或文件夹的名称:", _
Title:="源文件", Type:=2)
Destination = Application.InputBox(prompt:="请输入文件或文件夹的新名称:", _
Title:="目标文件", Type:=2)
spath = ThisWorkbook.Path & "\"
SourceFile = spath & sourctfile
Destination = spath & destinationfile
If Len(Dir(SourceFile, vbDirectory)) > 0 Then
Name SourceFile As destinationfile
MsgBox "重命名成功!"
Else
MsgBox "文件或文件夹" & SourceFile & "不存在!"
End If
End Sub
VBA重命名文件或文件夹
最新推荐文章于 2024-07-15 22:17:25 发布