'Microsoft.Office.Interop.Word in .NET 6.0 - Change builtin document property
Using the Microsoft.Office.Interop.Word.Document interface in C# you can get/set the document's built-in properties (Author, Title, Subject, Creation date,...) with this code:
dynamic docprops = document.BuiltInDocumentProperties;
dynamic prop = docprops[WdBuiltInPropertyEnum];
prop.Value = VALUE;
Marshal.ReleaseComObject(prop);
Marshal.ReleaseComObject(docprops);
which works fine if the VALUE is string. When the value is the System.DateTime
, the prop.Value
(for example WdBuiltInProperty.wdPropertyTimeLastPrinted
) is set to a new value, but when I read the same property again like
dynamic docprops = document.BuiltInDocumentProperties;
dynamic prop = docprops[WdBuiltInPropertyEnum];
VALUE = prop.Value;
the VALUE
returns unchanged date. Any idea why the property of type date is not updated?
Thanks for any help.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|