CustomDocumentProperties returns the entire collection of custom document properties. Use the Microsoft.Office.Core.DocumentProperties.Item(System.Object) property to return a single member of the collection (a Microsoft.Office.Core.DocumentProperties object) by specifying either the name of the property or the collection index (as a number).
private static void WordCustPropertyExample(Word.Application wAP )
{
// Custom Property Extraction For Word Document
Office.DocumentProperties oCusProps = (Office.DocumentProperties)wAP.ActiveDocument.CustomDocumentProperties;
foreach (Office.DocumentProperty oCusProp in oCusProps)
{
// MessageBox.Show( oCusProp.Name);
}
}
To add a custom property to the Word document using VSTO, use the add method as shown below
//Adding a Custom Property for Word Document
oCusProps.Add("CopyEdited By", false, Office.MsoDocProperties.msoPropertyTypeString, "
nice post. thanks.
ReplyDelete