Searching text in an OLE-Object (Word)

G

Guest

Hi,
in my table I have a field (type: OLE-Object) in which I store Word-documents.
Now I want to find all recordsets, which contain the text I am searching.
How can I do that?

I want to use a form with a textbox (txtSearch) and a command button
(cmdFind) to start the search.

Peter
 
S

Stephen Lebans

You cannot directly.
The OLE object would have to be activated and then use AUtomation to
have MS Word to search for the desired text.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
G

Guest

Hello Stephen,
thank you for your answer.

Stephen Lebans said:
You cannot directly.
The OLE object would have to be activated and then use AUtomation to
have MS Word to search for the desired text.

Well, now I have build a form with a textbox (txtSearchText), a checkbox
(chkWholeWord), a bound OLE Object (objWordText) and a button
(cmdStartSearch).
I use Automation and it works. I have a loop, to show every record.
Here is my code:

Private Sub cmdStartSearch_Click()
Dim OLEObj As Object
Do
If Not IsNull(Me.objWordText) Then
Set OLEObj = Me.objWordText.Object.Application
Me.objWordText.Action = acOLEActivate
With OLEObj.Selection.Find
.Text = Me.txtSearchText
.MatchWholeWord = Me.chkWholeWord
If .Execute Then
MsgBox "Found!"
End If
End With
Me.objWordText.Action = acOLEClose
Set OLEObj = Nothing
End If
DoCmd.GoToRecord , , acNext
DoEvents
Loop Until Me.NewRecord
End Sub

But it is slow and the commandbar changes for each record.

My hope was to have an API or any idea to work with a recordset. I don't
want to see every record, while searching through the table.


Peter

P.S.: I am sorry for my bad english.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top