Esempio n. 1
0
 private void SetWordDocumentPropertyValue(Word.Document document, string propertyName, string propertyValue)
 {
     try
     {
         object builtInProperties;
         builtInProperties = document.BuiltInDocumentProperties;
         Type builtInPropertiesType = builtInProperties.GetType();
         object property = builtInPropertiesType.InvokeMember("Item", System.Reflection.BindingFlags.GetProperty, null, builtInProperties, new object[] { propertyName });
         Type propertyType = property.GetType();
         propertyType.InvokeMember("Value", BindingFlags.SetProperty, null, property, new object[] { propertyValue });
         document.UpdateSummaryProperties();
         document.Save();
     }
     catch (COMException ex)
     {
         if (ex.ErrorCode == -2146824090)
         {
             // No problem, user just cancelled out of the save as dialog
             return;
         }
     }
 }