I'm trying to populate a PowerPoint presentation with a new smart art on each slide, using VBA. I've come up with a code which basically does that, using:
Dim myShape As Shape
Set oSALayout = Application.SmartArtLayouts( _
"urn:microsoft.com/office/officeart/2005/8/layout/hChevron3")
Set myShape = curSlide.Shapes.AddSmartArt(oSALayout)
The only issue with this code is that, when I use it on a new slide with a basic layout (one Title box and one Content container), the SmartArt is attached to the content box and makes it disappear. The box is technically still in the Shapes list but has its HasSmartArt attribute set to true. So in practice, the SmartArt replaces the box. However, if I add a bit of text in the content box before running the code, VBA creates a Diagram object for the SmartArt. I tried creating manually a shape but there is no way (as far as I have found) to tell the code which shape to attach to.
Therefore, I would like to know if someone has a solution. In practice, I will mostly use the code on new empty slides, but I would like to be sure that it does not erase any other object without my noticing.
Thank you for your help
Following @steve-rindsberg advice, I add a text flag to all empty placeholders to "protect" them before adding the SmartArt, and remove the text afterwards. (simply testing with curShape.Type = msoPlaceholder
and curShape.TextFrame.TextRange = ""
)