I am trying to change some CustomDocumentProperties for a .docx document. I was able to read the current value and change it, but when I save the document, changes to user fields are lost.
I have the following method in the DocAccessor class (which serves as an interface for my doc files):
void SetInfo(string key, string val) {
object custom_properties = current_doc.CustomDocumentProperties;
Type custom_properties_type = custom_properties.GetType();
custom_properties_type.InvokeMember("Item", BindingFlags.Default | BindingFlags.SetProperty, null, custom_properties, new object[] { key, val });
}
elsewhere i call:
doc_accessor.GetInfo("Number")
doc_accessor.SetInfo("Number", "6");
doc_accessor.GetInfo("Number")
doc_accessor.SaveAndClose();
doc_accessor.Open();
doc_accessor.GetInfo("Number")
The my doc_accessor.SaveAndClose () function works correctly, as I changed the save path to another location, and this happened ... but without writing the modified CustomDocumentProperties. This makes it seem like there is some kind of commit step that I am missing, but should current_doc.Save () not handle this?
Mrspo