Quantcast
Channel: General Office Development forum
Viewing all articles
Browse latest Browse all 2257

Getting error when adding a custom smartart shape in PowerPoint

$
0
0

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: SmartArts

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

Viewing all articles
Browse latest Browse all 2257

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>