|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
可在2003版本下试试如下代码(未经优化):
- Sub PickRedRange()
- Dim sPat As String, sStr As String
- Dim nNum As Long, wDoc As Document, wRng As Range
- With Application.FileDialog(msoFileDialogFolderPicker)
- If .Show <> -1 Then Exit Sub
- sPat = .SelectedItems(1) & ""
- End With
- sStr = ""
- Application.ScreenUpdating = False
- With Application.FileSearch
- .LookIn = sPat
- .FileType = msoFileTypeWordDocuments
- For nNum = 1 To .Execute
- sStr = sStr & Mid(.FoundFiles(nNum), Len(sPat) + 1, Len(.FoundFiles(nNum)) - Len(sPat) - 4) & vbCrLf
- Set wDoc = Documents.Open(.FoundFiles(nNum), Visible = False)
- Set wRng = wDoc.Range
- With wRng.Find
- .ClearFormatting
- .Font.Color = wdColorRed
- Do While .Execute
- sStr = sStr & wRng & vbCrLf
- Loop
- End With
- wDoc.Close False
- Next
- End With
- Application.ScreenUpdating = True
- ActiveDocument.Range.InsertAfter vbCrLf & sStr
- End Sub
复制代码 注:类似问题论坛中应该有现成案例可参考的,可通过搜索查找出来。 |
评分
-
1
查看全部评分
-
|