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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With