我想在Visio中迭代某些形状,我有一个可行的解决方案,但是它有点低,因为存在很多形状(也许一千种,而我只想迭代二十或三十个)其中):
Dim shp As Visio.Shape
Dim pagShape As Visio.Shape
Set pagShape = Visio.ActivePage.PageSheet
For Each shp In Visio.ActivePage.Shapes
If InStr(shp.Data3, "_tag") Then
If StrComp(Replace(shp.Data3, "_tag", ""), name) = 0 Then
shp.text = name
Else:
shp.text = ""
End If
End If
Next shp
是否可以在列表中添加一些形状而不是选择所有现有形状? 诸如此类:
For Each shp In List
非常感谢您:)
编辑:我已经这样做了:
声明和设置的部分:
Public Collection_shp As Collection
Set Collection_shp = New Collection
创建标签形状时,将其添加到集合中:
Collection_shp.Add Item:=vso_sg
还有循环部分:
Dim shp As Visio.Shape
For Each shp In Collection_shp
If InStr(shp.Data3, "_tag") > 0 Then
If StrComp(Replace(shp.Data3, "_tag", ""), name) = 0 Then
shp.text = name
Else
shp.text = ""
End If
End If
Next shp
答案 0 :(得分:0)
我已经做到了:
声明和设置的部分:
Public Collection_shp As Collection
Set Collection_shp = New Collection
创建标签形状时,将其添加到集合中:
Collection_shp.Add Item:=vso_sg
还有循环部分:
Dim shp As Visio.Shape
For Each shp In Collection_shp
If InStr(shp.Data3, "_tag") > 0 Then
If StrComp(Replace(shp.Data3, "_tag", ""), name) = 0 Then
shp.text = name
Else
shp.text = ""
End If
End If
Next shp