Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-21-2018, 05:24 AM
R Mohan R Mohan is offline VBA to add shapes to Smart Art Org Chart Windows 8 VBA to add shapes to Smart Art Org Chart Office 2016
Novice
VBA to add shapes to Smart Art Org Chart
 
Join Date: Apr 2018
Posts: 15
R Mohan is on a distinguished road
Default VBA to add shapes to Smart Art Org Chart

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 !
Reply With Quote
  #2  
Old 05-21-2018, 06:54 AM
JohnWilson JohnWilson is offline VBA to add shapes to Smart Art Org Chart Windows 7 64bit VBA to add shapes to Smart Art Org Chart Office 2016
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

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
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #3  
Old 05-22-2018, 04:33 AM
R Mohan R Mohan is offline VBA to add shapes to Smart Art Org Chart Windows 8 VBA to add shapes to Smart Art Org Chart Office 2016
Novice
VBA to add shapes to Smart Art Org Chart
 
Join Date: Apr 2018
Posts: 15
R Mohan is on a distinguished road
Default Thank you very Much !!!

Hi John,

Amazing ! The code worked !

Thanks a ton for your time and help !
Reply With Quote
  #4  
Old 05-22-2018, 04:42 AM
JohnWilson JohnWilson is offline VBA to add shapes to Smart Art Org Chart Windows 7 64bit VBA to add shapes to Smart Art Org Chart 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
  #5  
Old 06-18-2018, 12:43 PM
R Mohan R Mohan is offline VBA to add shapes to Smart Art Org Chart Windows 8 VBA to add shapes to Smart Art Org Chart Office 2016
Novice
VBA to add shapes to Smart Art Org Chart
 
Join Date: Apr 2018
Posts: 15
R Mohan is on a distinguished road
Default Thank you John

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
Reply With Quote
Reply

Thread Tools
Display Modes


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
VBA to add shapes to Smart Art Org Chart 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

Other Forums: Access Forums

All times are GMT -7. The time now is 02:12 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft