![]() |
|
#1
|
|||
|
|||
|
Hi,
With regard to Smart Art Org charts, 1) Is it possible to automatically add a node below the selected node using PowerPoint VBA? Something like the "Add Shape Below" feature? 2) Can we put in a condition, wherein - if the user does not select any node within the smart art org chart, he is prompted to select a node first. I am trying to make this a pre-condition before point 1 above can be initiated. It would be a great help to me if someone could help me with this ! |
|
#2
|
|||
|
|||
|
This should give you a start
Code:
Sub addShape()
On Error Resume Next
If ActiveWindow.Selection.ShapeRange(1).HasSmartArt Then
If Err <> 0 Then
MsgBox "select smart art"
Exit Sub
End If
'so far so good
If ActiveWindow.Selection.ChildShapeRange.Count = 1 Then
'One node selected
CommandBars.ExecuteMso ("SmartArtAddShapeAfter")
Else
MsgBox "Select ONE node"
End If
End If 'not Smart art
End Sub
|
|
#3
|
|||
|
|||
|
Hi John,
Amazing ! The code worked ! Thanks a ton for your time and help ! |
|
#4
|
|||
|
|||
|
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
|
|
#5
|
|||
|
|||
|
Hi John,
I know this 'thank you' mail is coming a bit late to you. At the outset, just wanted to say thanks for your timely help and expertise. Regards, Mohan |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Smart Art Org Chart - Is it possible to give a custom RGB color for each level within the hiearchy | R Mohan | PowerPoint | 7 | 04-30-2018 06:37 AM |
| Struggling with Smart Art | R Mohan | PowerPoint | 5 | 04-24-2018 08:35 AM |
| Dynamic Smart Shapes? | cloudforgiven | Excel | 0 | 11-21-2016 10:24 AM |
Smart Art - Updating a Chart
|
AD1983 | PowerPoint | 2 | 10-18-2016 06:26 AM |
| Is there a smart art that would do this? | raindog308 | Drawing and Graphics | 0 | 09-24-2010 04:23 PM |