I'm using MS Office interop assemblies to build a Powerpoint addin that inserts slides and charts on the fly. But during insertion it take up to 20 seconds to complete the process from inserting the slide to insertion of the chart.
After doing extensive logging, I noticed few lines of code where our application gets stuck for 20+ seconds. Here are those lines:
powerpointChartObj.SetSourceData(Source:=String.Format("=Sheet1!A1:B{0}", 5))
powerpointSlideObject.Shapes("some shape name")
We continuously play with PowerPoint chart and slide objects during the slide insertion process but some time it gets blocked on one of above lines. And it's random on which line it gets blocked.
Following are the office libraries we are using:
- Microsoft Office 16.0 Object Library
- Microsoft Excel 16.0 Object Library
- Microsoft Graph 16.0 Object Library
- Microsoft PowerPoint 16.0 Object Library
- Microsoft Word 16.0 Object Library
- Microsoft.Office.Tools.dll
- Microsoft.Office.Tools.Common.dll
- Microsoft.Office.Tools.Common.v4.0.Utilities.dll
- Microsoft.Office.Tools.v4.0.Framework.dll
- Microsoft.Vbe.Interop
Test Environemnt
Office 2016
Windows 8.1 + Windows 10
16 GB RAM, Intel Core i5-4570 CPU
Any solution or workaround would be highly appreciated.
PS. Also tried using Office 15.0 Object libraries
Updated
I've tried EnableEvents and set it false forever. It boost up the performance during chart insertion/update scenarios but if we continuously make calls to PowerPoint COM components(e.g. Shapes, slides etc. to manipulate PowerPoint things), PowerPoint gets stuck for around 20 seconds again. Not sure if there is anything similar to EnableEvents available in PowerPoint interop.