I tried to use "Microsoft.Office.Interop.PowerPoint" in a simple WPF, but I got an error which was caused by the first line:
Microsoft.Office.Interop.PowerPoint.Application myApp= new Microsoft.Office.Interop.PowerPoint.Application();
The error looks the following way:
An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional information: Cannot create instance of 'MainWindow' defined in assembly 'PowerPointApp, Version=1.0.0.0, Culture=neutral.
How to fix it? Should I add something to xaml?
答案 0 :(得分:0)
您是否尝试在WPF中托管PowerPoint UI?
我曾经构建了一个文档管理系统,它使用WebBrowser控件在WPF中托管PowerPoint。 如果您导航到WebBrowser控件中的pptx文件并安装了PowerPoint,它将打开它。
这是另一种更长篇的方法:Embedding-PowerPoint-presentation-player-into-a-WP
如果您只想操纵演示文稿内容而不使用PowerPoint UI,那么可能是另一个问题。您需要引用Office互操作程序集的正确版本,因为在Office 2007上构建的版本不支持Office 2010。