在 Visio 中循环 'Shape Data'

Cycle 'Shape Data' in Visio

抱歉,这看起来很基础,但我似乎找不到足够的文档。 我基本上需要在 Visio 16 中使用 VBA 在形状 sheet 上循环浏览 "Shape Data" 中的行。我正在寻找的代码(我想)看起来有点像这样:

sub printLabelsAndProps()
    for each x in UnknownGroupOfThings
        debug.print x.prop.DataAndDocuments
        debug.print x.prop.Supports
    Next
end sub

感谢帮助

如果您知道所有形状都具有 "DataAndDocuments" 和 "Supports" 属性,您可以使用类似下面的代码(否则您可能需要使用 .CellExists).此外,如果您的单元格包含计算字符串,那么您应该使用 .ResultStr() 而不是 .Formula。如果这些值是数字,你甚至可以不用 .Formula

Sub printLabelsAndProps()
    For Each x In ActivePage.Shapes
        Debug.Print x.Cells("Prop.DataAndDocuments").Formula
        Debug.Print x.Cells("Prop.Supports").Formula
    Next
End Sub

如果你想循环查看单个形状的所有属性,你可以这样做:

Sub showAllProperties(x As Shape)
    For i = 0 To x.Section(visSectionProp).Count - 1
        Debug.Print x.CellsSRC(visSectionProp, i, visCustPropsLabel).Formula
        Debug.Print x.CellsSRC(visSectionProp, i, visCustPropsValue).Formula
    Next
End Sub