|
139:双击进入所要处理的文件夹:
- Sub RenameFiles()
- '文件改名:把 ※ 修改为 ~
- On Error Resume Next
- Dim fd As FileDialog, i As Long, doc As Document, p As String, docName As String, oldName As String
- Set fd = Application.FileDialog(msoFileDialogFolderPicker)
- If fd.Show = -1 Then p = fd.SelectedItems(1) Else Exit Sub
- Set fd = Nothing
- If MsgBox("是否处理文件夹 " & p & " ?", vbYesNo + vbExclamation, "循环遍历文件夹_修改文件名") = vbNo Then Exit Sub
- With Application.FileSearch
- .NewSearch
- .LookIn = p
- .SearchSubFolders = True
- .FileName = "*.doc"
- If .Execute > 0 Then
- For i = 1 To .FoundFiles.Count
- oldName = .FoundFiles(i)
- docName = Replace(oldName, "※", "~")
- Name oldName As docName
- Next i
- MsgBox "处理完毕!共处理 " & .FoundFiles.Count & " 个文件!", vbOKOnly + vbExclamation, "循环遍历文件夹_修改文件名"
- Else
- MsgBox "未发现文件!", vbOKOnly + vbCritical, "循环遍历文件夹_修改文件名"
- End If
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|