I try to ungroup a SmartArt shape from code, but it always causes an error: "This member can only be accessed for a group".
However, it's working, if I right click on the SmartArt shape, and ungroup it.
How can I fix this?
My code is:
public void CreateSmartArt(PowerPoint.Shapes allShapes) { PowerPoint.Shape smartartShape = allShapes.AddSmartArt(IttPowerPoint.Instance.PowerPointApp.SmartArtLayouts["MyLayOut"], 0f, 0f, width, height); Marshal.ReleaseComObject(smartartShape); smartartShape = null; } Public void UngroupSmartArt(PowerPoint.Shape shape) { try { shape.Ungroup(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
Note: I am using VS Ultimate 2013, PowerPoint2013, C#
In VBA, you'd do it like so, asssuming a reference to the smartart shape in osh:
osh.Copy
osh.Delete
Set osh = ActiveWindow.Selection.SlideRange(1).Shapes.PasteSpecial(ppPasteEnhancedMetafile)(1)
With osh.Ungroup
.Ungroup
End With
Copy the SmartArt shape to the clipboard Delete it from the slide Paste it back onto the slide as an Enhanced Metafile Ungroup it then ungroup the result.
Voila. Shapes.
You'll want to pick up the top/left coordinates of the Smart Art before copying/deleting it, then apply them to the pasted EMF.