PDA

View Full Version : Excel SmartArt Organizational Chart - Name and Title



bkaracs
03-26-2017, 11:34 PM
Hi Everyone!

I'm working on a vba org chart maker in Excel, I'd like to use the "Name and Title" layout for it.
I want my code to set the text of the "Name" and the "Title" box also, but until know I did not find how to manipulate the text in the "Title" box.

For the "Name" I use this -> oSA.Nodes(1).TextFrame2.TextRange.Text = "Name of the employee"

Does anyone know, how I can manipulate the "Title" text of a node?

Thanks in advance!
Balazs

Paul_Hossler
03-27-2017, 07:31 AM
I used some intermediate variables to trace through and check myself, but this seems to work

18779



Option Explicit
Sub Test()
Dim oShape As Shape
Dim oSA As SmartArt
Dim oNode As SmartArtNode

Set oShape = ActiveSheet.Shapes(1)

If oShape.HasSmartArt Then
Set oSA = ActiveSheet.Shapes(1).SmartArt
Set oNode = oSA.AllNodes(1)

oNode.Shapes(1).TextFrame2.TextRange.Text = "John"
oNode.Shapes(2).TextFrame2.TextRange.Text = "Boss"

End If

End Sub

bkaracs
03-27-2017, 07:35 AM
Hi Paul!

Thanks a lot, thats exactly what I was looking for, works perfectly. :)

Br,
Balazs