我需要确保适用于 Visio 2003 的宏不会在较低版本的 Visio 上引起问题:特别是因为我正在写入一个在较低版本的 Visio 上不存在的属性。目前我正在这样做:
...
On Error GoTo NoComplexScriptFont:
Set cellObject = shapeObject.Cells("Char.ComplexScriptFont")
On Error GoTo ErrHandler
...
NoComplexScriptFont:
Rem MSGBOX only for debug
MsgBox "No Such Property"
GoTo endsub
ErrHandler:
Rem put in general error handling here
GoTo endsub
endsub:
End Sub
...
哪个有效,但我认为它有点混乱。我玩弄了使用“Application.version”的想法(对于 Visio 2003 返回“11”),但我想避免假设任何特定版本中可用的属性,而只是测试属性本身。
在 VBA 中执行此操作的正确习语是什么?
谢谢
---在下面得到了一些答案,我首选的解决方案是这个:
If shapeObject.CellExists("Char.ComplexScriptFont", 0) Then
msgbox "Property exists"
else
msgbox "Property does not exist"
end if