在 C# 中访问 Power Point 文件的文档属性
我需要访问 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:
无法将类型为“System.__ComObject”的 COM 对象转换为接口类型“Microsoft.Office.Core.DocumentProperties”
我有一个文件选择器对话框,我可以在其中选择演示文稿和然后将其传递给 TestProperties 方法。
I need to access Power Point properties like Author, Organization..
How can I do that?
EDIT:
This is what I am trying:
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;
}
This gives me ClassCastException:
Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Core.DocumentProperties'
I have a file chooser dialog where I choose the presentation and then pass it to TestProperties method.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我有一个可用的 C# 代码,可以使用 OLE 自动化(Microsoft.Office.Interop.PowerPoint):
已通过 Microsoft PowerPoint for Office 365(版本16.0)。
感谢 https://wditot。 wordpress.com/2012/05/10/extracting-metadata-from-ms-office-docs-programmatically。
I have a working C# code to read / write document properties for PowerPoint documents, using OLE automation (Microsoft.Office.Interop.PowerPoint):
Tested and works as expected with Microsoft PowerPoint for Office 365 (version 16.0).
Thanks to https://wditot.wordpress.com/2012/05/10/extracting-metadata-from-ms-office-docs-programmatically.
这样的事情对你有用吗..?更改属性[“”]以适合您的情况
Will something like this work for you..? change the properties[" "] to fit your case