使用VBA,如何检索自定义从一个Visio 2003图表形状信息。

有帮助吗?

解决方案

要获取的定制形状从一个Visio形状信息:

Function GetCustomPropertyValue(TheShape As Visio.Shape, ThePropertyName As String) As String
    On Error Resume Next
    GetCustomPropertyValue = TheShape.CellsU("Prop." & ThePropertyName).ResultStr(visNone)
End Function

所有这些功能确实是使用上的形状cellsu属性来获取通过名称自定义属性的ShapeSheet单元格...

如果你是一个有关使用上的错误继续下一步坚持己见的人,你可以检查首先检查是否存在细胞,如果细胞存在:

if TheShape.CellExistsU( "Prop." & ThePropertyName , 0 ) then
GetCustomPropertyValue = TheShape.CellsU("Prop." & THePropertyName).ResultStr(VisNone)

其他提示

找到此,在 http://visio.mvps.org/VBA.htm (自定义属性)

Public Sub CustomProp()
    Dim shpObj As Visio.Shape, celObj As Visio.Cell
    Dim i As Integer, j As Integer, ShpNo As Integer
    Dim LabelName As String, PromptName As String, ValName As String, Tabchr As String

    Open "C:\CustomProp.txt" For Output Shared As #1

    Tabchr = Chr(9)

    For ShpNo = 1 To Visio.ActivePage.Shapes.Count
        Set shpObj = Visio.ActivePage.Shapes(ShpNo)
        nRows = shpObj.RowCount(Visio.visSectionProp)
        For i = 0 To nRows - 1
            Set celObj = shpObj.CellsSRC(Visio.visSectionProp, i, 0)
            ValName = celObj.ResultStr(Visio.visNone)
            Set celObj = shpObj.CellsSRC(Visio.visSectionProp, i, 1)
            PromptName = celObj.ResultStr(Visio.visNone)
            Set celObj = shpObj.CellsSRC(Visio.visSectionProp, i, 2)
            LabelName = celObj.ResultStr(Visio.visNone)

            Debug.Print shpObj.Name, LabelName, PromptName, ValName
            Print #1, shpObj.Name; Tabchr; LabelName; Tabchr; PromptName; Tabchr; ValName
        Next i
    Next ShpNo

    Close #1
End Sub
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top