I created 3 smartart shapes, and put them into the folder: "C:\Users...\AppData\Roaming\Microsoft\Templates\SmartArt Graphics", and the PowerPoint load them successfully. You can call them from the UI, however if at the beginning once the PowerPoint is opened, and I add a smartart shape into slide programmatically, I always get the following error:
"The index into specified collection is out of bounds"
However If I add my smartart shape from UI first, there is no error if I want to add my smartart shape from code after that.
My smartart shapes: smartart resources
My code is:
Microsoft.Office.Core.SmartArtLayout myLayout = null; try { myLayout = PowerPointApp.SmartArtLayouts["SmartArtABS3"]; } catch (Exception ex) { MessageBox.Show(ex.Message); questionLayout = null; } if (questionLayout != null) { PowerPoint.Shape smShape = allShapes.AddSmartArt(myLayout, left, top, width, height); //..... }
Note: I am using VS Ultimate 2013, PowerPoint 2013, C#, Add-In-Express