使用VBA将连接器的宽度更改为Visio中的特定对象

时间:2017-07-24 19:12:04

标签: vba visio

我尝试创建一个宏来更改连接到特定块的连接器的厚度。这就是我到目前为止所做的:

Private Sub HighlightPaths_Click()

Dim selection As Shape
Dim connections() As Long
Dim i As Integer

'Msgbox glued shapes
If ActiveWindow.selection.Count = 0 Then

MsgBox ("Select a shape then click this button.")

Else

'Set shape to current selection
Set selection = ActiveWindow.selection(1)

'Get array of connectors on selected object
connections() = selection.GluedShapes(visGluedShapesAll1D, "")

'Resize connectors to that shape [ERROR HERE]   
For i = 0 To UBound(connections())
    connections(i).Cells("LineWeight").Formula = "0.5 pt"
Next

End If
End Sub

我知道这是因为我试图以不适用的类型访问Cells属性。我是否必须在主形状列表中搜索Glue方法的返回值以查找动态连接器主形状?

1 个答案:

答案 0 :(得分:0)

数组连接()包含连接的形状ID。 在更改线宽之前,您需要获取形状对象。

  

ActivePage.Shapes(connections(i))。Cells(" LineWeight")。公式=" 0.5 pt"