|
借用DU老师的代码,写一个……。
- Sub 遍历所有文件夹中的文件()
- Dim arr(1 To 100000) As String, i&, k&, x&, f$, f1$, oDoc As Document
- Dim Osec As Section, Ohefo As HeaderFooter
- Application.ScreenUpdating = False
- With Application.FileDialog(msoFileDialogFolderPicker)
- If .Show = False Then Exit Sub
- arr(1) = .SelectedItems(1) & ""
- End With
- i = 1: k = 1
- Do While i < UBound(arr)
- If arr(i) = "" Then Exit Do
- f = Dir(arr(i), vbDirectory)
- Do
- If InStr(f, ".") = 0 And f <> "" Then
- k = k + 1
- arr(k) = arr(i) & f & ""
- End If
- f = Dir
- Loop Until f = ""
- i = i + 1
- Loop
- For x = 1 To UBound(arr)
- If arr(x) = "" Then Exit For
- f1 = Dir(arr(x) & "*.doc*")
- Do While f1 <> ""
- Set oDoc = Documents.Open(arr(x) & f1, Visible:=True)
- Selection.WholeStory
- Selection.Font.Color = wdColorBlack
- oDoc.Close True
- Set oDoc = Nothing
- f1 = Dir
- Loop
- Next x
- Application.ScreenUpdating = True
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|