我正在使用VS2012和c#开发Word 2010插件。这个插件的目的是增强一些文档属性,如"标签"、"关键字"、"类别"等。
我认为一定有一个相当简单的方法来与这些交互使用文档对象模型,但到目前为止,我还没有找到正确的属性来获取/设置。
如果有人能给我指出正确的方向我会很高兴的…:)
您可以访问BuiltInDocumentProperties
集合来访问这些属性:
foreach (DocumentProperty property in
Globals.ThisDocument.Application.ActiveDocument.BuiltInDocumentProperties)
{
Trace.TraceInformation("Name: {0}tValue: {1}tType{2}",
property.Name, property.Value, property.Type);
}
也可以通过其名称访问特定的属性:
DocumentProperty keywords = Globals.ThisDocument.Application
.ActiveDocument.BuiltInDocumentProperties["Keywords"];
Trace.TraceInformation("Name: {0}tValue: {1}tType{2}",
keywords.Name, keywords.Value, keywords.Type);