Sadly JACOB is only one part of the equation.

The first thing you need to do is get your hands on or install the help for
VBA into your copy of Word. This will tell ou how to manipulate the Word
Object Model, something that you will need to know about of before embarking
on a project like this one. With JACOB you will be automating the execution
of VBA like commands. This is not a working example but they look something
like this;

Workbooks.Open("C:\Data\Book1.xlsx")

The complete model is divided into Objects, Methods, Collections, Events and
Enumerations (I think that's the lot) and you will need the help files on
hand to find out which gets you what.

Word also has a Macro recorder feature, learn to make use of that. A Macro
is simply a collection of VBA commands that perform some operation. Word
allows you to record them and will create the macro to perform a search
operation, for example, by recording the steps you would perfomr to use the
application itself to accomplish this task.

OLE/COM is slow - you will be running an instance of Word in the background.
It is also impossible to trap and errors that may occur. Word was designed
to be manipulated by a person and it notifies the user of errors by popping
up an error message and waiting for a response. You cannot trap or catch
these (at least as far as I am aware) from within the Java code that will be
driving the application.

To return to your original problem, what you will get when you perform the
search operation is either a Range or a Selection object. I do not know
whether it is possible to track back from these to the page they are on but
am certain you can get at their exact location within the document relative
to other items of text. It might be worth looking at the object model to see
if there is a Pages collection. If there is, you can get this from the
document and iterate through each page performing the relevant search. All
you then need to do is find the accompanying reference number value for the
search term and is should be fairly easy to do this by searching backwards
and using regular expressions to search for a match.

All the best.

Yours

Mark B



--
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/Problem-integrating-Apache-POI-into-NetBeans-tp5711909p5711992.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to