Dim app As New MSWord.Application
try
Dim dlg As New FolderBrowserDialog
If dlg.ShowDialog = DialogResult.Ok Then
MessageBox.Show("需要检索的文档目录是:" & dlg.SelectedPath,"提示")
End If
Dim s As String = ""
For Each file As String In FileSys.GetFiles(dlg.SelectedPath)
If file.ToLower.EndsWith(".doc") Then
Dim doc = app.Documents.Open(file)
Dim gjz As String = Tables("说明书检索").Current("说明书关键字")
If app.ActiveWindow.Selection.Find.Execute(gjz) = False Then
Doc.close
Else
s = s & IIF(s>"", vbcrlf, "") & file
End If
End If
Next
If s > "" Then
MessageBox.Show("共计找到包含关键字的文档有count个,目录如下:" & vbcrlf & s,"关键字文档查找",MessageBoxButtons.OK,MessageBoxIcon.None)
Else
MessageBox.Show("没有找到包含关键字的文档","关键字文档查找",MessageBoxButtons.OK,MessageBoxIcon.None)
End If
app.Visible = True
catch ex As exception
msgbox(ex.message)
app.Quit
finally
End try
想自动统计出包含关键字文档的数量,怎么统计呢?count这块该怎么改?
MessageBox.Show("共计找到包含关键字的文档有count个,目录如下:" & vbcrlf & s,"关键字文档查找",MessageBoxButtons.OK,MessageBoxIcon.None)