2012-01-03 36 views
1

我需要访问作者,组织等Power Point属性..访问C#中Power Point文件的文档属性

我该怎么做?

编辑:

这就是我想:

static void TestProperties(Presentation presentation) // Microsoft.Office.Interop.PowerPoint.Presentation; 
      { 
       Microsoft.Office.Core.DocumentProperties properties; 
       properties = (Microsoft.Office.Core.DocumentProperties)presentation.BuiltInDocumentProperties; 

       Microsoft.Office.Core.DocumentProperty prop; 

      } 

这给了我ClassCastException异常:

无法投型 '系统.__ ComObject' 到接口类型“微软的COM对象.Office.Core.DocumentProperties'

我有一个文件选择器对话框,我选择演示文稿,然后将其传递给TestProperties方法。

+0

嘿,检查编辑。 – vale4674 2012-01-03 15:24:59

回答

0

会有这样的东西为你工作..?更改属性[“”]以适合您的情况

Microsoft.Office.Core.DocumentProperties properties; 
properties = (Microsoft.Office.Core.DocumentProperties) 
    Globals.ThisWorkbook.BuiltinDocumentProperties; 
Microsoft.Office.Core.DocumentProperty prop; 
prop = properties["Revision Number"]; 
+1

另外(当然在将PowerPoint Com Object引用添加到您的项目之后),也可以使用'Microsoft.Office.Interop.PowerPoint.Presentation'。 – ToddBFisher 2012-01-03 15:09:52

+0

这是一个很好的答案,因为.NET可以很好地使用Interop和非托管COM .. +1对于Todd也是如此 – MethodMan 2012-01-03 15:11:49

+0

@ToddBFisher我已经引用了'Microsoft.Office.Interop.PowerPoint.Presentation'对象(演示文件I我感兴趣的)在我的代码,但我无法找到我需要的信息。 – vale4674 2012-01-03 15:13:49