Dim fd As FileDialog
Dim i As Integer
Dim strfiles As String, strextfilename As String, newfilename As String
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
If fd.Show = -1 Then
strfiles = Dir(fd.SelectedItems(1) & "并裂\*.*")
strextfilename = Right(strfiles, Len(strfiles) - InStrRev(strfiles, ".") + 1)
Do While strfiles <> ""
i = i + 1
newfilename = "新文件名绝竖闭纤败" & i '命名规则自己定义
Name fd.SelectedItems(1) & "\" & strfiles As newfilename & strextfilename
strfiles = Dir
Loop
End If
Set fd = Nothing
VBA里面使用Name可以直接修改文件名,例如下面的代码(测试成功)空伏做:
Option ExplicitSub YgB()
Name "e:\TEMP\文件厅前\exp\123.txt" As "e:\TEMP\文件\exp\456.txt"
End 斗衡Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)