2011-04-05 28 views
2

当我尝试将该属性设置为隐藏PPT演示:PowerPoint.ApplicationClass().Visible = False如何使用COM/IronPython的

我收到以下错误信息:

"Invalid request. Hiding the application window is not allowed." 

,我发现这个old thread在eggheadcafe。所以我修改了我的代码,如下所示:

com_ppt = self.com_app.Presentations.Open(filename, WithWindow = False) 

但是,这只隐藏了PRESENTATION,但仍然打开APPLICATION窗口。所以,基本上,PPT打开了,但里面没有演示。任何帮助这个神秘将不胜感激。

回答

2

这就是我想到的。似乎到目前为止:

if self.isVisible: 
    self.com_app.Visible = self.isVisible 
com_ppt = self.com_app.Presentations.Open(filename, WithWindow = isVisible) 

据我所知,你只能设置“可见”等于true。如果您尝试将其设置为False,则会窒息。但是,如果要隐藏窗口,则不能将Visible设置为true,然后将其设置为false。看起来有一个Visible的第三个状态(比如“undefined”或者“default”),为了将WithWindow设置为False并让ppt应用程序保持关闭状态,可见的必须位于第三个状态。

0

WithWindow必须msoFalse:

WithWindow: Microsoft.Office.Core.MsoTriState.msoFalse