try my code. I am able to replace the bookmark values. On Tue, Jun 19, 2012 at 11:26 PM, Mark Beardsley [via Apache POI] < [email protected]> wrote:
> Firstly, no, this code will not work for .doc files. POI is able to > support both file types - binary (.doc) and OOXML (.docx) - bt it uses two > different code bases to support them. The example code is targeted at the > OOXML file format so you can only use it with .docx files. There is an > example on the list showing how to work with .doc files but that is not my > code. If you search through the posts on the list, I am confident you will > find it. I can try to put together an example from memory but cannot > promise when this will be. > > Secondly, it will not replace the text you have at the bookmark positions; > it can only insert text into the document either immediately in front or > behind of the bookmarked text. If you want the code to replace the text at > the bookmarks position then it is up to you to modify the example so that > it performs in this way. I think that everything you need to see is there; > all you need to do is > > 1. Get the node for the bookmaerkStart tag. > 2. Iterate along the nodes until you find the bookmarkEnd tag. Remove > these unwanted nodes from the document as you go. > 3. Once you hit the bookmarkEnd tag, create a new run to hold the text you > wish to insert into place. > 4. Insert that into the document immediately in front of the bookmarkEnd > tag. > > Dig around in the DCOXTest class and you should see how to step through > the nodes, how to find out which node you are dealing with, etc. I will > take a look at the code you attached to your last message and get back to > you as soon as possible. > > I will try running the code to recover bookmarks against your document - > thanks for that by the way - and let you know whether it works for tables. > It should and I hope it does because I do already know it will insert text > at bookmarks within table cells. Again, will post to this thread. > > Yours > > Mark B > > ------------------------------ > If you reply to this email, your message will be added to the discussion > below: > > http://apache-poi.1045710.n5.nabble.com/How-to-read-the-value-of-bookmarks-docx-tp5710184p5710245.html > To unsubscribe from How to read the value of bookmarks? (docx), click > here<http://apache-poi.1045710.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5710184&code=c3VwcmF0aW0uY2hha3JhYm9ydHlAZ21haWwuY29tfDU3MTAxODR8MTg0MTQ1MzIzNA==> > . > NAML<http://apache-poi.1045710.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > -- * With thanks,* *Supratim* -- View this message in context: http://apache-poi.1045710.n5.nabble.com/How-to-read-the-value-of-bookmarks-docx-tp5710184p5710246.html Sent from the POI - User mailing list archive at Nabble.com.
