I have both ObjRexx and Regina and on a Windows-based environment if that
makes a difference.
Thanks,
Gary Richtmeyer
Lee Peedin
VP RexxLA
On 32 bit Windows you could use the w32funcs DLL available at
http://home.interlog.com/~ptjm/ to access the Word documents using OLE.
Here's a simple example that opens a document, steps through the 'Words'
collection and displays each word on the screen:
/* Example of OLE automation with Word. */
call rxfuncadd 'w32loadfuncs', 'w32util', 'w32loadfuncs'
call w32loadfuncs
wrd = w32CreateObject("Word.Application")
documentscollection = w32getproperty(wrd,"Documents")
myFile = "C:\Documents and Settings\Administrator\My
Documents\Rexx\w32funcs\wordread.doc"
document = w32CallFunc(documentscollection,"Open",'s',myFile)
wordcount = w32getproperty(document,"Words.Count")
if datatype(wordCount,"N") then do i = 1 to wordCount
wordref = w32getsubobj(document,"Words","I",i)
say w32getproperty(wordref,"Text")
end
cleanup:
call w32CallProc wrd, "FileClose"
call w32ReleaseObject wrd
call w32olecleanup
call w32dropfuncs
/* End of example */
WATCH for line wraps ! ! ! !
/* testword.rex */
wrdObj = .oleObject~new("Word.Application")
text = 'Gary Richtmeyer'
doc_spec = 'c:\Documents and Settings\Administrator\My
Documents\*.doc'
call SysFileTree doc_spec,mydocs.,'f' -- Get all Word
docs in specific folder
do aa = 1 to mydocs.0 -- Obtain just the
filename
entry_length = length(mydocs.aa)
cpos = pos("c:",mydocs.aa) - 1
fname = substr(mydocs.aa,cpos,entry_length-cpos+1)
call Search_Doc fname
end
wrdObj~quit
exit
Search_Doc:
parse arg current_doc
wrdObj~Visible = .False
wrdObj~Documents~Open(current_doc)
if wrdObj~Selection~Find~Execute(text) then
aline = 'Found'
else
aline = 'Did NOT Find'
aline = aline text "In" current_doc
say aline
wrdObj~Documents~Close()
return
On Tue, 6 Jul 2004 08:43:02 -0400, "Gary Richtmeyer"
<glricht-R...@imailbox.com> wrote:
I'll give both examples a try and see how it goes.
Gary Richtmeyer
"Gary Richtmeyer" <glricht-R...@imailbox.com> wrote in message
news:p4OdnaxXX43...@giganews.com...
Hi!
If using an external application is an option, you might consider
http://wvware.sourceforge.net/
This is a library which allows access to word documents and runs on
quite a lot plattforms. The distribution contains a small utility named
wvText which converts Word files to plain ASCII text.
I used the library a few years ago and it worked quite good back then.
MfG
Sebastian