none
Sharepoint fields and Word Content Control limitation? RRS feed

  • Question

  • I'm pretty sure I have found a problem involving using Sharepoint fields as Content Controls in Word documents but I'd like to know if anyone can suggest a workaround (we're using SP 2010 and Word 2010).

    My Sharepoint document library has a specialized Word document as a template (it happens to contains macros (and so has a .docm extension) but I don't think that matters).  This template contains about 10 Content Controls that pull their data from the Sharepoint library.  Two of the Sharepoint fields are type Multi-Line which, according to what I've read, can store 1,073,741,823 characters (2gb of data).  However, I've discovered (by trial and error) that the Content Controls associated with these fields can only store 255 characters.  Once I open the document from the Sharepoint library in Word, I can't save it unless I delete most of the characters in these two fields. 

    The Content Controls for these fields default to being PlainText (I'm guessing this is connected to the MultiLine format of the Sharepoint fields) but I've noticed that there is a RichTextFormat Content Control (wdContentControlRichText).  Does this type of Content Control have the same character limitations?   (I found a few references from 2008 to a similar problem with Sharepoint content types but wasn't sure how that applied to my situation.)

    Is there any way to remove the character limitation (from either type of Content Control) via a Macro or a VSTO Add-in?  If not, what alternatives are possible given that the document has to be stored in Sharepoint and edited in Word? 

    Thanks in advance for your help.  Carol.

    Thursday, May 17, 2012 6:38 PM

Answers

  • Turns out that it was a XML thing.  The XML for the fields I was having problems with looked like this:

    </xsd:element>
    - <xsd:element name="ProjectOverview" ma:index="10" nillable="true" ma:displayName="ProjectOverview" ma:internalName="ProjectOverview">
    - <xsd:simpleType>
    - <xsd:restriction base="dms:Note">
      <xsd:maxLength value="255" />
      </xsd:restriction>
      </xsd:simpleType>
      </xsd:element>

     but the field that worked didn't have the   <xsd:maxLength value="255" />  line.  So I deleted the problematic fields and recreated them.  All is well now.  Thanks again.  Carol.

    • Marked as answer by cpnc Tuesday, May 22, 2012 4:10 PM
    Tuesday, May 22, 2012 4:10 PM

All replies

  • HI cpnc,

    Thanks for posting in the MSDN Forum.

    What's the mean of Sharepoint Fields? Can I conside it as the content control on the template?

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Friday, May 18, 2012 2:02 AM
    Moderator
  • Sorry for the confusion Tom.  By "Sharepoint fields" I meant the columns (metadata, maybe) that are in the Sharepoint document library where the Word document lives (guess I haven't gotten out of the database world...).  I hope this helps.  Thanks.  Carol.
    Friday, May 18, 2012 2:00 PM
  • In a simple example here, I don't see this restriction. When I define the column in Sharepoint as type "Muiltiple  lines of text" I get a choice of "Yes" or "No" for "Allow unlimited length in document libraries". Incidentally, if I choose "Yes", there's a warning that some applications won't work with texts over 255.

    If I choose "No", I can't put more than 255 characters in the field in the Sharepoint library. If I choose "Yes", I can. When I open the document in WOrd, all those characters show in the DIP and in any associated content control, and I can add more in Word and save/close the document back to Sharepoint.

    If I look in Word VBA at Activedocument.ContentTypeProperties.Type for multiline properties, there is no distinction - they are both type 14 ("Note"). But if I look inside the .docx at the XML schema for the properties (which is created "on the fly" by Sharepoint), one property's schema shows a restriction of 255 characters length and the other does not.

    Without looking further I can't be sure, but in the example I'm using I don't have an associated document template (cf. your .docm). So here, the schema is being generated on-the-fly, as I said. But I'm wondering whether Sharepoint always tries to use the schema in a template associated with the Sharepoint library, in which case the problem could be that the template's schema and the actual data type of the column in the library are different.

    You could check that, and also check inside a document's XML to see what the schema looks like - in the XML, it's in one of the xml files under \customXml and will be named something like item3.xml. 

    Another thought is that if the sharepoint column is only restricted to 255 characters when you enter data in the Sharepoint UI, if you are actually populating the column using some process on Sharepoint that can bypass that constraint, there could also be a problem. (I do not know if that is possible, and it sounds rather unlikely to me, but perhaps worth a look)

    FWIW I don't know what the character count limit for a plain text content control is, but it probably is quite large. The thing about rich text content controls is that you can't connect them to an item in the Custom XML data store.


    Peter Jamieson

    Monday, May 21, 2012 12:01 AM
  • Good ideas, Peter.  So I just tested using a multi-line field with a dotx, dotm, and docm template and found that I was able to save a document in a Sharepoint Library when the multi-line field was filled with 2000 characters.  I AM trying to enter the characters into the field by a .NET application + Sharepoint Web Services so I thought your point about bypassing the Sharepoint UI might be the cause of my problem.  However, even when I did create a document from Sharepoint using my current template, I still had the problem of not being able to save the document when a multi-line field contained 2000 characters.

    So my next step is to look at the XML as you suggested.  Thanks for all the good ideas.  Carol.

    Tuesday, May 22, 2012 3:32 PM
  • Turns out that it was a XML thing.  The XML for the fields I was having problems with looked like this:

    </xsd:element>
    - <xsd:element name="ProjectOverview" ma:index="10" nillable="true" ma:displayName="ProjectOverview" ma:internalName="ProjectOverview">
    - <xsd:simpleType>
    - <xsd:restriction base="dms:Note">
      <xsd:maxLength value="255" />
      </xsd:restriction>
      </xsd:simpleType>
      </xsd:element>

     but the field that worked didn't have the   <xsd:maxLength value="255" />  line.  So I deleted the problematic fields and recreated them.  All is well now.  Thanks again.  Carol.

    • Marked as answer by cpnc Tuesday, May 22, 2012 4:10 PM
    Tuesday, May 22, 2012 4:10 PM
  • Glad to hear it. Before you get much further, it may also be worth verifying that your Word documents and your library are all using the same namespace GUID (you'll find the namespace appears

    ...in the schema XML in the Word document, somewhere like

    ct:contentTypeSchema/xsd:schema[1]/xmlns:ns2

    and

    ct:contentTypeSchema/xsd:schema[1]/xsd:import/namespace

    and

    ct:contentTypeSchema/xsd:schema[2]/targetNamespace

    and is used in the custom XML part where the data values are held.

    I don't know where you would need to look on the Sharepoint site for that, but I expect the people in the Sharepoint forums here can help you out more.


    Peter Jamieson

    Tuesday, May 22, 2012 4:21 PM