Assuming you are using TraversalUtil (eg
https://github.com/plutext/docx4j/blob/ ... inder.java ),
then you can get from the bookmarkStart to the list containing that object, via getParent.
Then you can delete the content between bookmarkStart and bookmarkEnd, and add a run containing your text.
I guess it would be useful to add a method which does this for you .. A robust version would handle the case where the bookmarkEnd is not in the same paragraph.
Note that for a simple looking sentence:
This is a sentence with a empty slot in it.
Word may generate rather verbose XML:
Using xml Syntax Highlighting
<w:p>
<w:pPr>
<w:rPr>
<w:lang w:val="en-AU"/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:lang w:val="en-AU"/>
</w:rPr>
<w:t xml:space="preserve">This is a sentence with
</w:t>
</w:r>
<w:proofErr w:type="gramStart"/>
<w:r>
<w:rPr>
<w:lang w:val="en-AU"/>
</w:rPr>
<w:t>a
</w:t>
</w:r>
<w:proofErr w:type="gramEnd"/>
<w:r>
<w:rPr>
<w:lang w:val="en-AU"/>
</w:rPr>
<w:t xml:space="preserve"> </w:t>
</w:r>
<w:bookmarkStart w:id="0" w:name="bm1"/>
<w:r>
<w:rPr>
<w:lang w:val="en-AU"/>
</w:rPr>
<w:t>e
</w:t>
</w:r>
<w:r>
<w:rPr>
<w:lang w:val="en-AU"/>
</w:rPr>
<w:t xml:space="preserve">mpty slot
</w:t>
</w:r>
<w:bookmarkEnd w:id="0"/>
<w:r>
<w:rPr>
<w:lang w:val="en-AU"/>
</w:rPr>
<w:t>in it.
</w:t>
</w:r>
</w:p>
Parsed in 0.003 seconds, using
GeSHi 1.0.8.4
I'll write some code to do this for you, if you can hang on...