Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBA - Using .onAction on SmartArtNodes

Tags:

excel

vba

I am new to VBA and trying to use smartArt.Nodes to dynamically generate an organizational chart based on some cell data. I am able to generate the chart with no problems. Now, I would like to be able to display more details of specific nodes of the chart by clicking on them. I am aware that we can convert smartArts into Shapes with the Drawing Tools in Excel and then use .onAction on them like:

ActiveSheet.Shapes(name1).OnAction = "detail"

However, is there a way to achieve the same thing with smartArt.nodes using VBA? Say I have a node called "nodes1" I have tried:

nodes1.Shapes.OnAction = "detail"

or

Dim objShape As Shape
Dim SmartArtNod As SmartArtNode
Set objShape = ActiveSheet.Shapes(1)
Set SmartArtNod = objShape.SmartArt.AllNodes(1)

SmartArtNod.Shapes(1).OnAction = "detail"

and other combinations, but none of them seem to work... Thank you for your help!

like image 991
Catherine Avatar asked May 26 '26 13:05

Catherine


1 Answers

Hard to prove a negative, but I believe this is not possible. Testing with Excel 2013, I can confirm the following do not work:

  • Trying to trap the Selection of the SmartArt using Worksheet_SelectionChanged does not fire. If you change the selection from a cell to the SmartArt object, you will not get an event. You will get an event however when you lose focus on the SmartArt and go back to the cell.

  • You can select a SmartArt object and then debug to check what is selected. The object is of type Object/Shape and the watch window indicates that it exposes an OnAction property, but attempting to set this property will throw an error.

I take the two issues above to mean that is will be very difficult (if not impossible) to get an OnAction event to fire from the SmartArt.

like image 73
Byron Wall Avatar answered May 28 '26 03:05

Byron Wall



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!