none
Bookmark on CheckBox and replace the text with open XML RRS feed

  • Question

  • Hello .

    I have the following situation : A template with some bookmarks . Some of these bookmars are on checkboxes (form field).

    1) How can i replace the bookmark with actual text ?

    2) How can i update the value of the checkbox?

    Until now i found a solution that i don;t like for the first question :

    using (WordprocessingDocument package = WordprocessingDocument.Open(docName, true)) { var mainPart = package.MainDocumentPart; var bmStart = from book in mainPart.Document.Body.Descendants<BookmarkStart>() where bok.Name == bookmarkName select book; var bookmark = bmStart.SingleOrDefault(); var parent = bookmark.Parent;

    Paragraph para = new Paragraph(new Run(new Text("TEXT"))); parent.InsertAfterSelf(para); package.Close(); }


    What i don't like about this solution is that the text is inserted after the bookmark (creating a new line) and not instead of the bookmark.

    For the second question i was not able to create anything.

    Any help would be much appreciated.

    Thank you.

    Friday, June 29, 2012 7:41 AM

Answers

  • Hi florea.lucian,

    It's based on my experience that the text will in the place where between <BookmarkStart> and <BookmarkEnd> tags. The tags might in different Paragraphs tag's range. So I would recommand you export the <BookmarkStart> and <BookmarkEnd> tags in order the to find out what content in it to replace.

    Have  a good day,

    T.X.


    征诛志异,三让两家王朝
    功同开辟,一桮万古江南


    Saturday, June 30, 2012 3:00 AM