vbams-officevisiooffice-2003

How do I retrieve Visio custom shape information with VBA


Using VBA, how do I retrieve custom shape information from a Visio 2003 diagram.


Solution

  • To get custom shape information from a Visio shape:

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

    All this function does is uses the cellsu property on a shape to get the custom property ShapeSheet cell by name...

    If you're a stickler about using the on error resume next, you can check to see if the cell exists by first checking if the cell exists:

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