Bookmarks behavioral in docx word format RRS feed

  • Question

  • How is Bookmarks behavioral in docx word format.  Does bookmarks follow sequential/tree structure in docx when we see document.xml file?

    In below word/Document snippet, when we select text as bookmarked, why the bookmarkStart appears after P tag and it’s properties. And why bookmarkEnd ends after P tag end.

    <w:p w:rsidRDefault="009123BC" w:rsidP="000B4D99" w:rsidR="006819FD"><w:pPr><w:pStyle w:val="Title"/><w:spacing w:after="0"/></w:pPr><w:bookmarkStart w:name="Table_of_Content" w:id="0"/><w:r><w:t xml:space="preserve">TABLE OF  CONTENT</w:t></w:r></w:p><w:bookmarkEnd w:id="0"/>

    How to remove bookmarks along with content from document.xml in this kind of XML’s. Do bookmarkStart tag reference somewhere in files to get their contents?

    Monday, April 22, 2013 9:12 AM


  • Hi Chethan

    I'm not sure I understand your question...

    The bookmark Start and End tags reflect what the user sees when viewing the document with the bookmark non-printing characters visible. A bookmark will start where the selection at the time of the bookmark creation began and end where the end of the selection was.

    In general terms, a bookmark can start anywhere and end anywhere. Multiple bookmarks can overlap; they're paired by the w:id attribute.

    There is no additional information about bookmarks anywhere in a Word Zip package - all of it's right there.

    And yes, this does make bookmarks tricky to manipulate in the XML environment. That's a major reason why content controls are the recommended way to "target" data these days. If you know you're looking for a bookmark with the name "Table_of_Content", that it takes this form and that you'd want to remove the entire paragraph, then you'd locate the bookmark start, then delete the next higher level in the XML hierarchy, which would be the entire paragraph (parent node) and lastly the bookmark end element with the matching w:id attribute.

    Cindy Meister, VSTO/Word MVP, my blog

    Monday, April 22, 2013 3:44 PM