Skip to content

Instantly share code, notes, and snippets.

@felixlindemann
Created August 11, 2013 15:35
Show Gist options
  • Save felixlindemann/6205386 to your computer and use it in GitHub Desktop.
Save felixlindemann/6205386 to your computer and use it in GitHub Desktop.
C# - VSTO - WriteCustomDocumentProperties
private void WriteDocumentProperty(string propertyName, string value)
{
Microsoft.Office.Core.DocumentProperties properties;
Document doc = this.getDoc();
properties = (Microsoft.Office.Core.DocumentProperties)
doc.CustomDocumentProperties;
if (properties.Cast<DocumentProperty>().Where(c => c.Name == propertyName).Count() == 0)
properties.Add(propertyName, false, MsoDocProperties.msoPropertyTypeString, Guid.NewGuid().ToString());
properties[propertyName].Value = value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment