我想使用办公自动化(PIA)某些 .PPTX
文档转换成其他格式。然而,PowerPoint中坚持表示,即使在主窗口隐藏一个进度条。
有没有什么办法可以prevent PowerPoint无法显示过任何Windows主桌面?
额外信息:
我主要是使用C#,COM PIA为Office互操作。但我不怕挖成C ++:P
我开始使用PIA这样的PowerPoint
VAR应用=新PowerPoint.Application();
。VAR PPT =约presentations.Open(my.pptx);
//此行会显示一个进度对话框
ppt.SaveAs(out.pdf
PowerPoint.PpSaveAsFileType.ppSaveAsPDF,
MsoTriState.msoTrue);
app.Quit();
解决方案
您可以使用的 CreateDesktop
调用调用PowerPoint演示过程之前创建备用桌面。这将确保由PowerPoint创建的窗口是不可见的。但是,也有一些需要注意的地方在这里:
您也可以尝试使用 Windows消息钩确定创建窗口时,并保持不可见。这也有一些需要注意的地方:
您必须找到确定的感兴趣窗口的某种可靠的方式(窗口类名?) 如果PowerPoint中的进程外的服务器,会出现一个窗口,你的钩子是活动的,可能会隐藏错误的进度对话框(例如,一个属于另一个进程)。为了尽量减少这种机会,测试以查看是否简报是在进程(在这种情况下,程序的钩只影响自己的过程),并且如果没有,安排钩子仅是活动的的必要时间,以晚饭的最小量preSS进度窗口。 在未来的PowerPoint版本可能会打破无论您使用的方法来识别感兴趣的窗口。有一点你可以做这个。I'm trying to use Office Automation (PIA) to convert some .pptx
documents into some other formats. However, PowerPoint insists on showing a progress bar even the main window is hidden.
Is there any way I can prevent PowerPoint from ever displaying any Windows to the main desktop?
Extra information:
I am mainly using C#, COM PIA for Office interop. But I'm not afraid to dig into C++ :P
I start PowerPoint using PIA like this
var app = new PowerPoint.Application();
var ppt = app.Presentations.Open("my.pptx");
// This line will show a progress dialog
ppt.SaveAs("out.pdf",
PowerPoint.PpSaveAsFileType.ppSaveAsPDF,
MsoTriState.msoTrue);
app.Quit();
解决方案
You can use the CreateDesktop
call to create an alternate desktop before invoking the powerpoint process. This will ensure that windows created by powerpoint are not visible. However, there are a number of caveats here:
You could also try using a Windows Message Hook to determine when the window is created and keep it invisible. This also has a number of caveats:
You'll have to find some reliable way of identifying the window of interest (window class name?) If powerpoint is an out-of-process server, there will be a window in which your hook is active and might hide the wrong progress dialog (ie, one belonging to another process). To minimize this chance, test to see if powerpoint is in-process (in which case program the hook to only affect your own process), and if not, arrange for the hook to only be active for the minimum amount of time necessary to suppress the progress window. Future powerpoint releases may break whatever method you use to identify the window of interest. There's little you can do about this one.