Vba 更改组中线条的颜色
我想更改我的示意图中线条的适当性。Vba 更改组中线条的颜色,vba,visio,Vba,Visio,我想更改我的示意图中线条的适当性。 代码可以工作,除非行在一个组中 Dim shp As Visio.Shape For Each shp In Visio.ActiveWindow.Selection '// Add cell and formula/results here: shp.Cells("linecolor") = 0 Next shp Set shp = Nothing End Sub 对于每个形状,您需要检查组中的形状数,即 shp.s
代码可以工作,除非行在一个组中
Dim shp As Visio.Shape
For Each shp In Visio.ActiveWindow.Selection
'// Add cell and formula/results here:
shp.Cells("linecolor") = 0
Next shp
Set shp = Nothing
End Sub
对于每个形状,您需要检查组中的形状数,即 shp.shapes.count>0 然后在这些形状上迭代设置线条颜色 对于shp.shapes中的每个shp2
当然,这些形状中的每一个也可能是一个组,因此这里需要调用递归例程。这是我的最终代码,以防其他人会发现相同的问题:
For Each shp In Visio.ActiveWindow.Selection
shapeCount = shp.Shapes.Count
If shapeCount > 0 Then
For Each shp2 In shp.Shapes
'// Add cell and formula/results here:
shp2.Cells("linecolor") = 0
Next shp2
End If
Next shp
我建议你把你的“奖金问题”单独列为一个问题。非常感谢!它似乎工作正常,事实上,如果有子组,它就不工作了,所以我将尝试找到如何设置递归例程。它们可以让你在不接触任何形状的情况下改变颜色。可以使用该特性在VBA中更改图层的颜色。