none
How to create databinding between custom property value and content control such as Text? RRS feed

  • Question

  • hi.

    i see from insert command ,in word application, i can set a document part that databinding between core property value and content control.

    and then in the document.xml will have below xml string:

     

    <w:sdt><w:sdtPr><w:alias w:val="Title"/><w:tag w:val=""/><w:id w:val="-1167479764"/><w:placeholder><w:docPart w:val="AD94B6A579344943BFDEFD3F0B2A8BDA"/></w:placeholder><w:dataBinding w:storeItemID="{6C3C8BC8-F283-45AE-878A-BAB7291924A1}" w:xpath="/ns1:coreProperties[1]/ns0:title[1]" w:prefixMappings="xmlns:ns0='http://purl.org/dc/elements/1.1/' xmlns:ns1='http://schemas.openxmlformats.org/package/2006/metadata/core-properties' "/><w:text/></w:sdtPr><w:sdtEndPr/><w:sdtContent><w:p w:rsidRDefault="0011081F" w:rsidR="009F5A04"><w:r><w:rPr><w:rFonts w:hint="eastAsia"/></w:rPr><w:t>this is a title</w:t></w:r></w:p></w:sdtContent></w:sdt>

    now ,i want to binding the document custom property to content control, maybe i can change the path attribute and  set the storeitemid of document custom property ?

    how to do this?

    thanks!

    matt


    DON'T TRY SO HARD,THE BEST THINGS COME WHEN YOU LEAST EXPECT THEM TO.

    Monday, April 9, 2012 4:45 PM

All replies

  • Sorry for not answering your question but in case you are creating your own mail merge/document generation solution maybe you should check a 3rd party solution. Take a look at this toolkit.
    Thursday, April 12, 2012 11:04 AM
  • Jurij Leskovec.

    Thanks for your idea.

    the toolkit you point is so cool anyway.

    but it cann't match my need.

    i am in a project that using Word Document to Data Exchange between Some Application.

    every application would update the Word Document Custom Property Value, and then these values will display in Document Content.

    if i use Document Core Property like Summay ,Title,Author ,etc, i can using "Insert Document Part" Command to Binding these Core Properties Value to Plain Text Content Control,and them will update automatelly value when anyone of them modified.

    but ,it seem that there is not way to binding the Custom Property Values to this Plain Text Content Control,

    as well , i can you insert "Field" Document Part to display these Document Custom Property. but when i use Field, they cann't update auto, i must using VBA Macro to Update these Field Part.

    Finnay So. I upzip the .DOCX File ,and Discovery the <w:databinding> Element for Core Document Property and Plain Text Content Control,I think maybe i can use this xml element do like Databinding action between Custom Property and then Plain Text Content Control.

    thanks.


    DON'T TRY SO HARD,THE BEST THINGS COME WHEN YOU LEAST EXPECT THEM TO.

    Friday, April 13, 2012 1:23 AM
  • Ok, I think I understand you now. Why do you want to use data binding mechanisms of the content control? If control the logic of each application that programmatically changes custom properties in a document, then why don't you do the following when one of the applications updates a document:

    1. Use Open XML SDK to read current custom document property values and update them (to be available in the next update of the next document).

    2. Use Open XML SDK to set the content of the <w:sdt> element manually (don't use bindings).

    Friday, April 13, 2012 2:00 PM
  • hi.

    it must use databinding ,because my customer just only can update the document property value.

    and they do not or have not permission to update the document content.

    it seem that databinding is just only way to update content auto.

    thanks.


    DON'T TRY SO HARD,THE BEST THINGS COME WHEN YOU LEAST EXPECT THEM TO.

    Friday, April 13, 2012 2:49 PM
  • Hello Matthew,

    we have the same Problem like you in our project. Have you found any solution?

    Thanks and greetings from Germany

    Dennis

    Thursday, May 24, 2012 2:00 PM
  • no yet!

    Momentarily. We use Office Word Field to Map Custom Properties.


    DON'T TRY SO HARD,THE BEST THINGS COME WHEN YOU LEAST EXPECT THEM TO.


    Friday, May 25, 2012 2:47 AM