以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  可以判断word文档里面是否包含某一串字符吗?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=175582)

--  作者:lxhmax
--  发布时间:2022/3/10 14:26:00
--  可以判断word文档里面是否包含某一串字符吗?
可以判断word文档里面是否包含某一串字符吗?
--  作者:有点蓝
--  发布时间:2022/3/10 14:50:00
--  
参考:http://foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=70797&skin=0
--  作者:lxhmax
--  发布时间:2022/3/10 15:40:00
--  
老师,这个查找可以定位到查找到的数据在哪一页吗?

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>"", chr(13), "") & file
            End If
        End If
    Next
    If s > "" Then
        MessageBox.Show("共计找到包含关键字的文档有" & s.Split(chr(13)).Length & "个,目录如下:" & 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


--  作者:有点蓝
--  发布时间:2022/3/10 15:52:00
--  
网上搜了一遍,没找到相关用法
--  作者:lxhmax
--  发布时间:2022/3/10 18:55:00
--  
页眉跟页脚的数据搜索不到的吗?
--  作者:有点蓝
--  发布时间:2022/3/10 20:19:00
--  
搜索不到