Can I ask how you are going to be running the code please? The reason I ask is that I do have code that will insert text at bookmarks perfectly successfully but it relies upon OLE/COM. This means that you will be restricted to running the code on a Windows box (I have still not tested it on Linux under Wine even though I am assured it is possible to run Office that way).
If all you are creating is a utility that you will use to ruin on a Windows box then the code may be satisfactory and you are quite welcome to it. Just let me know. Furthermore, it should be possible to achieve something very similar using UNO and Open/LibreOffice. At one time, I had an application that used this API to accomplish something similar but that was two PC's ago and I cannot seem to find the code now. It is there, somewhere, and I will continue to look for it. The advantage of the UNO approach is, of course, platform independence - anything that will run open.LibreOffice will run the UNO client app. Also, it should be possible to get your hands on the URE (UNO Runtime Environment) so that the full Open/LibreOffice application does not need to be deployed. Yours Mark B PS. It should be possible to insert text at bookmarks using HWPF. I had a quick play and, as it is possible to get at the start and end offsets of both bookmarks and character runs it should be possible, in principal at least, to step through the character runs, get their start and end offsets, look to see if they 'encapsulate' a bookmark, find out what the bookmarks name is and substitute the required text. I have put together a very simple piece of code that sort of does this but only with a single bookmark in a single run of text. I suspect it would be necessary to re-save the document after each substitution however as modifying one range may corrupt others. XWPF is a different matter; I have not made any progress with that although it should be possible to simply insert the run between the strat and end bookmark elements. -- View this message in context: http://apache-poi.1045710.n5.nabble.com/Replacing-the-value-of-the-bookmarks-tp5710052p5710085.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]
