首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >VBA获取连接器'from shape‘和'to shape’

VBA获取连接器'from shape‘和'to shape’
EN

Stack Overflow用户
提问于 2011-07-11 21:52:16
回答 2查看 5.6K关注 0票数 2

我在Excel中有一个流程设计(使用形状、连接线等)。我需要的是有一个矩阵,每个形状都有所有的前辈和后继者。在VBA中,我试图这样做:-我列出了所有的连接符(Shapes.AutoShapeType = -2) -对于每个连接符,我想要有形状的名称'from‘和形状的名称' to’。

我希望你能明白这一点。我找不到连接器的属性来检索此信息。

这就是我到目前为止所知道的:

代码语言:javascript
复制
Sub getTransitions()
    ''the sheet with the design
    Set designSheet = Sheets("DesignSheet")
    Set tempSheet = Sheets("temp") 'Sheets.Add

    lLoop = 0

    'Loop through all shapes on active sheet
    For Each sShapes In designSheet.Shapes

        'Increment Variable lLoop for row numbers
        With sShapes

           ''connector shape type
           If ((sShapes.AutoShapeType) = -2) Then
                lLoop = lLoop + 1
                tempSheet.Cells(lLoop + 1, 1) = sShapes.Name
                tempSheet.Cells(lLoop + 1, 2) = sShapes.AutoShapeType

               ''here I want to have for the sShapes the from shape and the to shape


            End If



        End With

     Next sShapes
End Sub

有没有人知道这些信息的形状参数?

EN

回答 2

Stack Overflow用户

发布于 2011-07-11 22:01:29

似乎使用the ConnectorFormat object returned by the ConnectorFormat property并研究BeginConnectedShapeEndConnectedShape属性可能是最好的选择。

票数 3
EN

Stack Overflow用户

发布于 2019-12-11 18:04:56

你可以使用类似这样的东西:

代码语言:javascript
复制
Set g = ActiveSheet
i = 1
For Each s In g.Shapes
    If ((s.AutoShapeType) <> -2) Then 'all shapes without connectors
        c = 0
        For Each s1 In g.Shapes
            If ((s1.AutoShapeType) = -2) Then 'only connectors
                With s1.ConnectorFormat
                   Set a = .BeginConnectedShape
                   Set b = .EndConnectedShape
                End With
                If a.Name = s.Name Or b.Name = s.Name Then
                    c = c + 1
                End If
            End If
        Next s1

        g.Cells(i, "A").Value = s.Name 'name of shape 
        g.Cells(i, "B").Value = c 'count of connectors

    i = i + 1
    End If
Next s
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6651137

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档