[英]Adding presentation to newly open PowerPoint application - exception
我要启动PowerPoint实例,以隐藏其窗口的方式向其中添加演示文稿(无论是新窗口还是现有窗口,都导致相同的问题)。 但是,我在PowerPoint中遇到运行时错误,提示: Application (unknown-member): Invalid request. There is no active presentation.
Application (unknown-member): Invalid request. There is no active presentation.
当一个窗口可见或已经打开了至少有一个演示文稿的PowerPoint实例时,它可以正常工作。 此外,当我在此运行时错误中单击“结束”时,它仍然正确创建了一个演示文稿。 我尝试同时使用NetOffice包装程序和Interop。
我正在使用32位Office 2016。
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)
它可以正常工作。
对于Powerpoint 2000及更高版本,该应用程序必须可见。 您可以使用以下方法启用此功能
if (app.Version >= 9)
{
app.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
}
请参阅本文以获取更多详细信息:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.