Set fieldproperties in word document


#1

Can I set fieldproperties in word document with your aspose.word?

Tested width this code:

System.IO.MemoryStream stream = new MemoryStream();
stream.Write(byteDoc,0,byteDoc.Length);
Document Doc = new Document(filePath);
Doc.CustomDocumentProperties["DocumentID"].Value = "000000";
Doc.Save(filePath);

The property value did not change i my document.

Using evualation version,


#2

We have tests that show setting custom and built in document properties works okay.

Please note that CustomDocumentProperties[name] returns null if the property is not in the document. I guess the null could have been returned in your case, followed by access to .Value which threw a null reference exception which could have been caught and silenced in one of your exception handlers and that’s why the document was not saved and the property was not updated.

You need to check if the property is not there, use CustomDocumentProperties.Add.


#3

Hi,

I've done some further tests on this and I think I've found a problem:

If the document has ever had any CustomProperties set everything is OK.

However, if the docment is new (I was using the DocBuilder demo) and you add a CustomDocumentProperty, save the document, the property is NOT saved.

Any Ideas?

Richard Eke MCSD .NET
Senior Technical Architect
Xansa


#4

Hi Richard,

Thanks for your tests and report. We will try to fix this as quickly as possible.


#5

This is fixed in Aspose.Word 2.5 that will be released in the next 1-2 days.

The problem was only for the first custom property in a document that did not have any custom properties before (it was using an OLE2 reserved property ID).

Also, check your code, accessing because

doc.CustomDocumentProperties[“DocumentID”]

does not automatically add a property if its not there, you need to check if its null and add it.


#6

Hi,

We have released Aspose.Word 2.5.

http://www.aspose.com/blogs/Roman.Korchagin/