我想启动 PowerPoint 实例,以隐藏其窗口的方式向其添加演示文稿(新的或现有的,都会导致相同的问题)。但是,我在 PowerPoint 中收到运行时错误,上面写着:
Application (unknown-member): Invalid request. There is no active presentation.
当一个窗口可见或已经打开了一个至少有一个演示文稿的 PowerPoint 实例时,它可以正常工作。此外,当我在此运行时错误中单击“结束”时,它无论如何都会正确创建演示文稿。我尝试使用 NetOffice 包装器和 Interop 本身。
我正在使用 Office 2016 32 位。
var app = new Application();
var ppt = app.Presentations.Add(Microsoft.Office.Core.MsoTriState.msoFalse);
// Or using NetOffice, which basically uses different namespaces
var netApp = new PowerPoint.Application();
var netPPt = netApp.Presentations.Add(MsoTriState.msoFalse);
我希望能够将演示文稿添加到隐藏窗口,因为netApp.Presentations.Add(MsoTriState.msoTrue)
它工作得很好。