|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Option Explicit
Sub test()
Dim wdApp As Word.Application, Items As FileDialogSelectedItems, strPath$
strPath = ThisWorkbook.Path & "\"
With Application.FileDialog(1)
With .Filters
.Clear
.Add "Word文档(doc?)", "*.doc?"
End With
.AllowMultiSelect = False
.InitialFileName = strPath
If .Show Then Set Items = .SelectedItems Else Exit Sub
End With
Application.ScreenUpdating = False
On Error Resume Next
Set wdApp = GetObject(, "Word.Application")
If Err <> 0 Then
Set wdApp = New Word.Application
End If
With wdApp.documents.Open(Items(1))
With .Content.Find
.ClearFormatting
.Text = "【*】"
.Forward = True
.MatchWildcards = True
Do While .Execute
With .Parent
With wdApp.ActiveDocument.Range(.Start + 1, .End - 1)
.HighlightColorIndex = wdYellow ' .Font.Color = wdColorYellow
End With
End With
Loop
End With
.Close True
End With
If Err <> 0 Then wdApp.Quit
Set wdApp = Nothing
Set Items = Nothing
Application.ScreenUpdating = True
Beep
End Sub
|
评分
-
1
查看全部评分
-
|