PC Review


Reply
Thread Tools Rate Thread

Opening office documents - minus application object

 
 
Irwin Williams
Guest
Posts: n/a
 
      12th Jan 2005
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




 
Reply With Quote
 
 
 
 
Irwin Williams
Guest
Posts: n/a
 
      12th Jan 2005
Hey,
In reply to this, some trolling around took me to two tools that kinda does
what I want to do ... i would appreciate help from anyone with insight into
how they work ...
1. Google Desktop Search (http://desktop.google.com) works by indexing
certain files on a person's hard drive (inclusive of O2k+ files).
2. Powergrep
This is a windows based program similar to the linux grep util. It is used
to search for text in files.
Anyone with insight into how i can port their functionality into a vba
context for word documents?

/irwin

"Irwin Williams" <(E-Mail Removed)> wrote in message
news:OSqu6cM%(E-Mail Removed)...
> 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
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change all cells from minus to plus and plus to minus Rockbear Microsoft Excel Worksheet Functions 3 10th Oct 2008 09:49 AM
CHANGE TRAILING MINUS TO BRACKETS OR PRECEEDING MINUS =?Utf-8?B?U29jYWwgQW5hbHlzdCBsb29raW5nIGZvciBoZWxw Microsoft Excel Misc 2 12th May 2006 07:17 PM
C:\Documents and...\... \Local Settings\Application Data vs C:\Documents and... \..\Application Data harryguy082589@gmail.com Windows XP Performance 5 10th Feb 2005 01:54 AM
C:\Documents and...\... \Local Settings\Application Data vs C:\Documents and... \..\Application Data harryguy082589@gmail.com Windows XP General 6 10th Feb 2005 01:54 AM
SUMPRODUCT Minus Minus =?Utf-8?B?VmF1Z2hhbg==?= Microsoft Excel Worksheet Functions 5 4th Jul 2004 11:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:24 AM.