如何使用VBA检索Visio自定义形状信息

Jon*_*old 5 vba visio office-2003 ms-office

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

Jon*_*ier 6

要从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
Run Code Online (Sandbox Code Playgroud)

所有这个函数都使用形状上的cellsu属性来按名称获取自定义属性ShapeSheet单元格...

如果你是关于使用接下来的错误恢复的坚持者,你可以通过首先检查单元是否存在来检查单元是否存在:

if TheShape.CellExistsU( "Prop." & ThePropertyName , 0 ) then
GetCustomPropertyValue = TheShape.CellsU("Prop." & THePropertyName).ResultStr(VisNone)
Run Code Online (Sandbox Code Playgroud)