我在Excel中有一个流程设计(使用形状、连接线等)。我需要的是有一个矩阵,每个形状都有所有的前辈和后继者。在VBA中,我试图这样做:-我列出了所有的连接符(Shapes.AutoShapeType = -2) -对于每个连接符,我想要有形状的名称'from‘和形状的名称' to’。
我希望你能明白这一点。我找不到连接器的属性来检索此信息。
这就是我到目前为止所知道的:
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有没有人知道这些信息的形状参数?
发布于 2011-07-11 22:01:29
似乎使用the ConnectorFormat object returned by the ConnectorFormat property并研究BeginConnectedShape和EndConnectedShape属性可能是最好的选择。
发布于 2019-12-11 18:04:56
你可以使用类似这样的东西:
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 shttps://stackoverflow.com/questions/6651137
复制相似问题