Wrong Replacement of Text Content if Bookmarks in Word DOCM Document are enclosing each other using Aspose.Words for Java

We are using Word templates with bookmarks enclosing each other in our company. We try to replace the text inside the bookmark from both bookmarks one after another.

In the given test case the text of both bookmarks is replaced and the text of both bookmarks remains in the document. But the inner bookmark and its text has NOT to remain in the document.

Before we used Aspose for automation we tried automation with MS-Word and OpenOffice/LibreOffice (UNO). With Word and OO the text of the bookmarks is substituted correctly and without error.

We would expect that Aspose would delete the inner bookmark and only the text of the outer bookmark would appear in the document. Please fix it.

I tested it with Aspose-words-21.8.0-jdk17.jar.

Example source code with input and output documents do you find here:
TestAspose 210819.zip (66.2 KB)

The file “TextFile [1] VB Out.docm” is the output with Visual basic macro. It contains the expected output.

“TextFile [1] Aspose Out.docm” is the result with Aspose. As you may see, the document contains both bookmarks with the corresponding texts.

The issue is similar but not identical with the support case WORDSNET-21830 which I have opened in February 2021 (thanks for fixing). I am sorry that I only noticed this second mistake now.

Kind regards
Heiko Voss


We have logged this problem in our issue tracking system. Your ticket number is WORDSNET-22642. We will further look into the details of this problem and will keep you updated here on the status of the linked issue. We apologize for any inconvenience.

The issues you have found earlier (filed as WORDSNET-22642) have been fixed in this Aspose.Words for Java 21.9 update.

Thank you very much for fixing! Now it’s working like a charm! (and thanks it didn’t take such a long time to fix it as the first support case WORDSNET-21830).
Really Great. Thumbs up!

Kind regards
Heiko Voß


Thanks for your feedback. In case you have further inquiries or may need any help in future, please let us know by posting a new thread in Aspose.Words’ forum.