Hi,
I'm using MS Access to crawl thru my file server and for all office files
get their properties.
MS released a dll that does this nicely (dsofile.dll).
However, I would also like to grab all the text out of specified documents
(.doc) but my current solution is (to me) too cumbersome.
this is a snippet:
<snippet>
Public Function getWordDocText(strFileName As String)
On Error GoTo Handle_Err:
Dim WordApp As Word.Application
Dim WordDoc As Word.Document
Dim copiedText As String
Set WordApp = CreateObject("word.application")
WordApp.Visible = False
WordApp.DisplayScreenTips = False
WordApp.DisplayAlerts = wdAlertsNone
If WordApp.Documents.Open(fileName:=strFileName).HasPassword Then
WordApp.ActiveDocument.Close
WordApp.Quit
Set WordApp = Nothing
Set WordDoc = Nothing
Exit Function
End If
Set WordDoc = WordApp.Documents.Open(fileName:=strFileName,
ReadOnly:=True)
'if you want to watch the selection process then make word visible
getWordDocText = WordDoc.Content.Text
'close it up
WordApp.ActiveDocument.Close
WordApp.Quit
Set WordApp = Nothing
Set WordDoc = Nothing
Exit Function
Handle_Err:
Call RecordError("m: getWordDocText > " & strFileName, Err.Number & " |
| " & Err.Description)
Resume Next
End Function
</snippet>
What the above code does is for a given document, it opens up the file,
using a word application object, uses the object to get its text and closes
up everything.
I have a couple thousand files, and a win98 machine.
I would love to know if there is a way around using the MS word application
object.
My question is inspired from the fact that win2k can do a full text search
of office documents, without having the office suite installed. I want to
do the same
Is this possible? Also, if anyone on this list knows of other lists i can
chk i would appreciate it
/irwin
Jonathan West - 14 Jan 2005 14:03 GMT
Hi Irwin,
No, you can't get the documents without opening Word, but you can
substantially speed up the process as you have described it. What you are
doing is opening and closing Word every time you open a document. This is
very slow. Open Word once, keep the WordApp object available and then use it
to open the documents.
This is an ideal application for a class module. Open Iord in the Initialize
event of the class module, and close it in the Terminate event. Then
GetWordDocText can be a method of the class. Word is then automatically
started when you create an instance of the class, and automatically closed
when you dispose of the instance.

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
> Hi,
> I'm using MS Access to crawl thru my file server and for all office files
[quoted text clipped - 53 lines]
>
> /irwin
Irwin Williams - 14 Jan 2005 17:05 GMT
Thanks for the response. Sorry about the x-post - had a little difficulty
finding the right group.
So is there a way to get the word application to operate completely in the
background. By this i mean, if the document is password-protected, I want
to leave it out of my indexing operation. And that applies for all
documents.
I believe this is needed, because I am indexing a relatively large number of
documents - 7000+. So i want to be able to leave the app running ...
Any help would be appreciated.
/irwin
> Hi Irwin,
>
[quoted text clipped - 68 lines]
> >
> > /irwin
Jonathan West - 17 Jan 2005 11:36 GMT
Hi Irwin,
Yes, you can set the Visible property of the WordApp object to False.

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
> Thanks for the response. Sorry about the x-post - had a little difficulty
> finding the right group.
[quoted text clipped - 92 lines]
>> >
>> > /irwin