Reputation: 1765
I am trying to open a PowerPoint presentation, and have it hidden. I am doing it this way:
app = new Microsoft.Office.Interop.PowerPoint.Application();
string presentation = "C:\\presentation.pptx";
Presentation p = app.Presentations.Open(presentation, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
It is the simplest thing, yet I receive an error saying:
Application (unknown member) : Invalid request. There is no active presentation.
However, if I switch the last parameter (which is the WithWindow parameter) to MsoTriState.msoTrue, the presentation opens fine.
Upvotes: 2
Views: 5599
Reputation: 1942
I've tried this one, and it works:
Presentation p = app.Presentations.Open(presentation,0, 0, 0);
Upvotes: 1
Reputation: 5083
The code provided in the question works correctly, but there is an important note:
In C# you have to leave Application.Visible
property with it's default value:
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.
Upvotes: 3
Reputation: 1426
Do you have any other add-ins that might be causing that error? I ran your code (from VBA) and it ran fine.
Upvotes: 1