I have table with a general field that stores a Microsoft Word document. The table has thousands of records. How do I search for a single word or phrase within the general field without having to open each record one at a time?
I don't think so. You'd be much better off storing the word docs in a memo field and extracting them with strtofile() as needed. Then they could be easily searched with a LOCATE/SCAN for.
Alternatively, leave the docs in folders and store only the path in the DBF. You can search files with low level file reads if you need speed and scalability, of filetostr() is the docs are small and speed isn't a primary concern.
In general using general fields is asking for trouble later since they are not easily extracted or manipulated.
As Brian has said, you can't directly search Word docs stored in general fields.
If the documents are fairly static, you could consider creating a new memo field, alongside the existing general field, to hold only the text of the document (as opposed to formatting, graphics, etc.). You can populate this field using some simple Automation code (REPLACE TextMemo WITH oDoc.Content.Text). Then, use VFP's normal string-handling functions to search the field.
Of course, you'd then have the problem of keeping that field up to date, plus the searching would in any case be slow.
Another approach might be to use Word itself to do the searching. I don't know how to do it, but it should be possible, using Automation, to open each document in turn and have Word search it.
Hope this helps.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.