Sub ChangeName()
Dim strName As String
strName = Application.InputBox("请输入你要添加文件名的前缀,如:1", "文件名前缀输入框")
Dim FilePath As String
FilePath = ThisWorkbook.Path & "\"
Dim OldName As String
Dim NewName As String
Dim fileName As String
fileName = Dir(FilePath)
Do While fileName <> ""
If fileName <> "123.xlsx" Then
OldName = FilePath & fileName
NewName = FilePath & strName & fileName
Name OldName As NewName
End If
fileName = Dir
Loop
End Sub
怎样修改下面的代码,在多个工作簿的文件名前面同时添加文件名的前缀25
答案:1 悬赏:0 手机版
解决时间 2021-02-03 07:27
- 提问者网友:抽煙菂渘情少年
- 2021-02-02 10:03
最佳答案
- 五星知识达人网友:你哪知我潦倒为你
- 2021-02-02 10:34
Sub ChangeName()
Dim strName As String
strName ="25"
Dim FilePath As String
FilePath = ThisWorkbook.Path & "\"
Dim OldName As String
Dim NewName As String
Dim fileName As String
fileName = Dir(FilePath)
Do While fileName <> ""
If fileName <> "123.xls" Then
OldName = FilePath & fileName
NewName = FilePath & strName & fileName
Name OldName As NewName
End If
fileName = Dir
Loop
End Sub
将这串代码复制到Excel的VBA中,保存为123.xls(97-2003格式),然后将要改名的文件,跟这个文件放到同一个文件夹中,运行就好了
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯