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 can try to leave Application.Visible
property with it's default value and pass MsoTriState.msoFalse
to WithWindow
paremeter when you open a presentation:
var application = new Application();
var document = application.Presentations.Open(fileName, MsoTriState.msoFalse, MsoTriState.msoFalse,
WithWindow: MsoTriState.msoFalse);
If you explicitly set Application.Visible
property to MsoTriState.msoFalse
you will get "Hiding the application window is not allowed" error.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.