2012-01-03 70 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