Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Smartart hierarchy nodes - can only fill in one textframe of each node

Tags:

excel

vba

I am trying to build an organization chart automatically from data in Excel using Excel VBA. It works out fine, however, I would like to have both textframes filled in. In the big textframe I would like to have filled in the description of the department, and in the smaller textframe I would have like to add the department code.

smartart hierarchy layout

smartart hierarchy layout

I can't find the code to access the smaller textframe.

Do While Source.Cells(Line, 1) <> ""
    If Source.Cells(Line, 3) = PID Then
        Set ParNode = QNode
        If Source.Cells(Line, 4) = 1 Then
        Set QNode = QNode.AddNode(msoSmartArtNodeDefault, msoSmartArtNodeTypeAssistant)
        Else: Set QNode = QNode.AddNode(msoSmartArtNodeBelow)
        End If
        QNode.TextFrame2.TextRange.Text = Cells(Line, 6)
        'here something needs to be added !!!

        CurPid = Source.Cells(Line, 2)
        If Not Found Then Found = True 'something was find


        'Source.Rows(Line).Delete
        'Line = Line + 1
        Call AddChildNodes(QNode, Source, CurPid)
        Debug.Print ("CurPid" & CurPid)
        Debug.Print ("line" & Line)
        Set QNode = ParNode
    'ElseIf Found Then    'it's sorted,so nothing else can be found
     '   Exit Do
    'Else

    End If
    Line = Line + 1
Loop
like image 574
Loi Thindim Avatar asked Nov 20 '25 00:11

Loi Thindim


1 Answers

the upper line (where your CEO-text is)

                               QNode.TextFrame2.TextRange.Text
***.SmartArt.AllNodes(...).Shapes(1).TextFrame2.TextRange.Text

the lower line where your smartart is empty:

***.SmartArt.AllNodes(...).Shapes(2).TextFrame2.TextRange.Text

you need to check if QNode.Shapes(2).TextFrame2.TextRange.Text works. if not, you may need to use .parent

source

like image 111
Dirk Reichel Avatar answered Nov 21 '25 14:11

Dirk Reichel



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!