Answered by:
Length of DocProperties in Word 2010

Question
-
In a database solution custom docproperties are written into the structured content of a document. Sometimes we can get quite long strings. Since Word 2010 they are cut after 255 characters. In 2007 and 2003 we haven't found a limit like this. If you look for the docproperties using the property-dialog on operating system level, you can see the complete strings. Is there a chance to change word's behaviour?
Thanks a lot for any support!
Monday, September 3, 2012 7:17 PM
Answers
-
In my experience, when using code to write to document properties they've always had a limit of 255 characters. In the UI, I've been able to type more than that, but never when writing to them using code (CustomDocumentProperties[index].Value = "string").
This is also documented in the MSDN documentation for the object, for multiple versions of Word:
http://msdn.microsoft.com/en-us/library/microsoft.office.tools.word.document.customdocumentproperties(VS.80).aspx
http://msdn.microsoft.com/en-us/library/bb447539(office.12).aspx (search for 255 to jump to the XML definition)
http://msdn.microsoft.com/en-us/library/office/microsoft.office.interop.word._document.customdocumentproperties(v=office.11).aspxCindy Meister, VSTO/Word MVP
Tuesday, September 4, 2012 9:15 AM
All replies
-
In my experience, when using code to write to document properties they've always had a limit of 255 characters. In the UI, I've been able to type more than that, but never when writing to them using code (CustomDocumentProperties[index].Value = "string").
This is also documented in the MSDN documentation for the object, for multiple versions of Word:
http://msdn.microsoft.com/en-us/library/microsoft.office.tools.word.document.customdocumentproperties(VS.80).aspx
http://msdn.microsoft.com/en-us/library/bb447539(office.12).aspx (search for 255 to jump to the XML definition)
http://msdn.microsoft.com/en-us/library/office/microsoft.office.interop.word._document.customdocumentproperties(v=office.11).aspxCindy Meister, VSTO/Word MVP
Tuesday, September 4, 2012 9:15 AM -
Hi Bluedoor,
Thanks for posting in the MSDN Forum.
I will mark Cindy's reply as an answer. Please feel free to unmark it if you feel it doesn't help you.
@Cindy,
Thanks for your great work.
Have a good day,
Tom
Tom Xu [MSFT]
MSDN Community Support | Feedback to us
Monday, September 10, 2012 6:28 AM -
I know this question is fairly old, but document variables are a good alternative for long values, as they can be much longer. According to this StackOverflow question, up to 65280 Unicode characters. They don't get saved in the document though, you would have to put it into some custom XML and retrieve it later when opening the document.
In code, you would refer to document variables using Document.Variables instead of Document.CustomDocumentProperties. In field tags, use DOCVARIABLE instead of DOCPROPERTY.
Thursday, October 8, 2015 4:32 PM