[英]Adding presentation to newly open PowerPoint application - exception
I want to start PowerPoint instance, add a presentation to it in a way that has its window hidden (either a new one or existing one, both result in the same issue). 我要启动PowerPoint实例,以隐藏其窗口的方式向其中添加演示文稿(无论是新窗口还是现有窗口,都导致相同的问题)。 However, I get run-time error in PowerPoint that says:
Application (unknown-member): Invalid request. There is no active presentation.
但是,我在PowerPoint中遇到运行时错误,提示:
Application (unknown-member): Invalid request. There is no active presentation.
Application (unknown-member): Invalid request. There is no active presentation.
When a window is visible or there is already a PowerPoint instance open with at least one presentation it works without a problem. 当一个窗口可见或已经打开了至少有一个演示文稿的PowerPoint实例时,它可以正常工作。 Moreover, when I click "End" in this Run-time error it correctly creates a presentation anyway.
此外,当我在此运行时错误中单击“结束”时,它仍然正确创建了一个演示文稿。 I tried using both NetOffice wrapper and Interop itself.
我尝试同时使用NetOffice包装程序和Interop。
I'm using Office 2016 32-bit. 我正在使用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);
I would like to be able to add presentation to the hidden window, as with netApp.Presentations.Add(MsoTriState.msoTrue)
it works just fine. 我希望能够将演示文稿添加到隐藏的窗口中,就像使用
netApp.Presentations.Add(MsoTriState.msoTrue)
它可以正常工作。
For powerpoint 2000 onwards, the application must be visible. 对于Powerpoint 2000及更高版本,该应用程序必须可见。 You can enable this by using the following
您可以使用以下方法启用此功能
if (app.Version >= 9)
{
app.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
}
See this article for further details: 请参阅本文以获取更多详细信息:
https://support.microsoft.com/en-us/help/285472/run-time-error-2147188160-on-activewindow-or-activepresentation-call-i https://support.microsoft.com/en-us/help/285472/run-time-error-2147188160-on-activewindow-or-activepresentation-call-i
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.