a problem when i try to delete properly a range delimited by a bookmark in a
I use the DeleteBookmarkContent method from a bookmarkNavigator instance.
The output result seems visually correct (the specified range is deleted) but in details I notice that some bookmarks (outside the range) are lost.
I attached you a sample project with a word document (test.doc).
The test document contains 2 main ranges delimited by 2 bookmarks (ptabA and ptabB).
Each main range contains other bookmarks (tabA and tabB to enclose tables, tabA1Col1, tabA1Col2 …. to enclose cells).
After the DeleteBookmarkContent call on ptabA bookmark, you will notice that :
- tabA1 bookmark is preserved => it should have been deleted because it was inside the range to delete
- ptabA2 bookmark is lost => it should have been preserved because it was outside the range to delete
only a sample doc, but I have hundred of doc templates containing this kind of
structure / range which I delete dynamically (with Word interop).
I’m not able to explain this behavior and I didn’t find a way to resolve it.
Please, could you give me a sample to get the right output result ?
I made another
test with same code and the test document converted to docx (test.docx).
Strangely the ouput result is a bit different :
Could you also
explain me why the result is different depending on the doc / docx
version used ?
For now everything worked well with the doc format and your library (I’m currently testing your product) and didn’t plan to convert all my doc templates to docx.
Based on this behavior, should I reconsider this point ?
Best regards ,
Regarding the issue (Updated on 7/31/2019)
We have confirmed that the reported “Nested bookmark not deleted while deleting bookmark content in Word document” is an issue and we have logged a defect report.
The fix for this issue will be included in our 2019 Volume 3 release which is expected to be available at the end of September, tentatively.
Regarding the issue (Updated on 8/5/2019)
We can reproduce that the bookmarks are removed improperly (both case 1 and case 2) while deleting bookmark content in the given Word document. We will validate on this and will provide you more details on 7th August 2019.
Please, could you try to fix this problem globally. We sent
you several examples but it’s hard to describe every possible case.
I guess it's not an easy work for you, but the behavior should be identical to MS Word one (even if the deleted range contains bookmarks that start or end outside this range).
We use this delete range principle in many models to be able to adjust the document content dynamically during the reporting process.
And since we can not update all our customers models, for the moment we can not use your library to process these models.
So we really hope the next release would be the good one 😊
Once again, we hope that you will succeed in correcting this defect in a generic and definitive way because we have a lot of templates in which we dynamically delete ranges, and the configuration / layout is never exactly the same. For this reason you should not only work on the cases presented in this ticket.
However, the need is always the same and quite simple because we never cross
bookmarks. By "crossing" we mean : [[...]......], which is a very complex and twisted case.
Excluding this case, deleting a range delimited by a bookmark should never result in the deletion of an object that is « visually » outside this range (especially bookmarks, even if they start or end at the edge of the deleted range). We know that your library doesn’t work like Word Automation, but we need the behavior / result to be exactly the same on this point.
Please, notice that the problem has been reported a year ago and we are still waiting for the fix to use your library in production.