Search code examples
c#office-interopcom-interopexcel-interop

How can I access excel properties like creation date with C# and Excel interop


I have to extract the creation date of an excel file using C# and Microsoft.Office.Interop.Excel.Worksheet. I will get the properties with

object props = myworkbook.CustomDocumentProperties;

Now I am not sure how to get the creation date from this object.


Solution

  • The Creation Date can be found in the BuiltinDocumentProperties property which returns a Microsoft.Office.Core.DocumentProperties collection that represents all the built-in document properties for the workbook.

    Microsoft.Office.Core.DocumentProperties properties;
    
    properties = (Microsoft.Office.Core.DocumentProperties)Globals.ThisWorkbook.BuiltinDocumentProperties; 
    
    Microsoft.Office.Core.DocumentProperty prop;
    prop = properties["Creation Date"]; 
    

    See How to: Read from and write to document properties for more information.