I am writing a WPF application in C# .Net 4, in which I am trying to open a PowerPoint application instance and then open a new presentation.
In general the code to do this looks like:
var myApp = new Microsoft.Office.Interop.PowerPoint.Application();
var myPres = myApp.NewPresentation(Microsoft.Office.Core.MsoTriState.msoTrue);
This works fine unless, as in my situation, Powerpoint loads vba AddIns when it opens, which take some time to load.
In this case, PowerPoint tries to open the new presentation, fails, and throws a COM Exception.
My current workaround is pretty horrible:
var myApp = new Microsoft.Office.Interop.PowerPoint.Application();
MessageBox.Show("Confirm that PPT has finished opening.");
var myPres = myApp.NewPresentation(Microsoft.Office.Core.MsoTriState.msoTrue);
Does anyone know of a way to either: 1) test for Powerpoint having finished opening? or 2) stop addins loading when creating a new Powerpoint.Application?
Or any other solution of course!
I can't find anything to this end in the Microsoft documentation or on StackOverflow.
Many thank for any help, Tim J