【问题标题】:Smartart hierarchy nodes - can only fill in one textframe of each nodeSmartart 层次节点 - 每个节点只能填写一个文本框
【发布时间】:2021-03-01 18:04:50
【问题描述】:

我正在尝试使用 Excel VBA 从 Excel 中的数据自动构建组织结构图。效果很好,但是,我想同时填写两个文本框。在大文本框中,我想填写部门的描述,在较小的文本框中,我想添加部门代码。

smartart hierarchy layout

我找不到访问较小文本框的代码。

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

【问题讨论】:

  • 您是否尝试过手动录制宏?
  • @DirkReichel:有吗?并查看结果?
  • @teylyn 你是对的......录制不会有帮助......但是还有其他工具可以完美运行:)
  • @DirkReichel 其他工具是什么意思?
  • 在我的回答中查看图片:)

标签: excel vba


【解决方案1】:

上面一行(您的 CEO 文本所在的位置)

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

您的 smartart 为空的下一行:

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

您需要检查QNode.Shapes(2).TextFrame2.TextRange.Text 是否有效。如果没有,您可能需要使用.parent

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-11-19
    • 1970-01-01
    • 1970-01-01
    • 2015-03-24
    • 2017-02-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多