View Single Post
 
Old 05-22-2018, 04:42 AM
JohnWilson JohnWilson is offline Windows 7 64bit Office 2016
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

It's close but it needs a little more error checking

Code:
Sub addShape()

On Error Resume Next
If ActiveWindow.Selection.ShapeRange(1).HasSmartArt Then
If Err <> 0 Then
MsgBox "Select smart art"
Err.Clear
Exit Sub
End If
'so far so good
Debug.Print ActiveWindow.Selection.ChildShapeRange.Count
If Err <> 0 Then
MsgBox "No nodes selected"
Err.Clear
Exit Sub
End If
If ActiveWindow.Selection.ChildShapeRange.Count = 1 Then
CommandBars.ExecuteMso ("SmartArtAddShapeAfter")
'One node selected
Else
MsgBox "Select ONE node"
End If
End If 'not Smart art
End Sub
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote