'''
e.Form.Controls("TextBox3").text = "" '清空
e.Form.Controls("Label2").text = ""
If e.Form.Controls("TextBox2").text = "" OrElse e.Form.Controls("TextBox1").text = "" Then
msgbox("请录入需检索信息!")
Return
Else
Dim app As New MSWord.Application
e.Form.Controls("Label2").text = "正在检索中......"
Dim st As Date = Date.Now '开始计时
try
Dim s As String = ""
Dim doc = app.Documents.Open(e.Form.Controls("TextBox1").text)
Dim gjzs As String = e.Form.Controls("TextBox2").text
Dim flag As Boolean = False
For Each gjz As String In gjzs.split("、")
app.ActiveWindow.Selection.WholeStory
With app.ActiveWindow.Selection.Find
.HitHighlight(gjz, RGB(255, 255, 0), , , , , , , True) '高亮显示找到的关键字
End With
If app.ActiveWindow.Selection.Find.Execute Then flag = True
If flag = False Then
e.Form.Controls("TextBox3").text = "没有找到!"
Doc.close
Else
’s = s & IIF(s>"", "、", "") & gjz
’e.Form.Controls("TextBox3").text = "找到包含的关键字有" & s.Split("、").Length & "个,如下:" & "、" & s & vbcrlf & "未找到包含的关键字有" & s.Split("、").Length & "个,如下:" & "、" & s
If e.Form.Controls("CheckBox1").Checked = True Then '是否打开word文档
app.Visible = True
Else
app.Visible = False
app.quit
End If
End If
Next
catch ex As exception
msgbox(ex.message)
app.Quit
finally
End try
e.Form.Controls("Label2").text = "检索完毕!" & "耗时: " & (Date.Now - st).TotalSeconds & "秒"
End If