Sets the value of the specified property.

 public void SetDocumentProperty(BuiltInProperty property, System.Object propertyValue)
Public Sub SetDocumentProperty(ByVal [property] As BuiltInProperty, ByVal propertyValue As Object)

A DocumentProperties.BuiltInProperty object that represents the built-in property to set.

An Object that represents the value of the property specified.

SetDocumentProperty will throw this exception if an invalid type is passed for the property.

  • CreationDate, EditTime and LastPrintedDate must be of type System.DateTime.
  • RevisionNumber must be of type int.
  • ScaleOrCrop and LinksUpToDate must be of type Boolean.

This feature is available in OOXML files (DOCX/DOCM) only.

Setting the value to null will clear any existing values.

This is the MS Word equivalent of File menu > Info > Show All Properties:

!DocumentPropertiesPanel.png|thumbnail, border=1!


//--- Set "Author" Property
WordTemplate wt = new WordTemplate();
wt.Open(@"c:\templates\Template.doc");
wt.SetDocumentProperty(DocumentProperties.BuiltInProperty.Author, "Jennifer WordSmith");
wt.Process();
wt.Save(@"c:\reports\Report.doc");
//--- Set "Author" Property
Dim wt As New WordTemplate()
wt.Open("c:\templates\Template.docx")
wt.SetDataSource(DocumentProperties.BuiltInProperty.Author, "Jennifer WordSmith")
wt.Process()
wt.Save("c:\reports\Report.docx")