【VSTO日常笔记一】如何使用VSTO获取Word文档的自定义属性

    xiaoxiao2023-10-26  159

    如何使用获取Word文档的自定义属性。NET (C#)

           CustomDocumentProperties 返回自定义文档属性的整个集合。 使用 Microsoft.Office.Core.DocumentProperties.Item(System.Object) 属性返回集合的单个成员 (一个 Microsoft.Office.Core.DocumentProperties 对象) 通过指定属性的名称或集合索引(作为数字)。

    private static void WordCustPropertyExample(Word.Application wAP ) { // 读取Word文档的自定义属性 Office.DocumentProperties oCusProps = (Office.DocumentProperties)wAP.ActiveDocument.CustomDocumentProperties; foreach (Office.DocumentProperty oCusProp in oCusProps) { // MessageBox.Show( oCusProp.Name); } } //要使用VSTO向Word文档添加自定义属性,请使用如下所示的添加方法 //向Word文档添加自定义属性的方法 oCusProps.Add("CopyEdited By", false, Office.MsoDocProperties.msoPropertyTypeString, "Santa Barbara", false);

    转载自:How to get the Custom Properties of a Word Document using VSTO

    最新回复(0)