我正在使用Visio 2013和VBA。我想从页面中隐藏的Shape I中检索Characters
。我试过了:
Dim s As Visio.shape
Dim c As Visio.Characters
Set s = ActiveWindow.Selection.ContainingShape
c = s.Characters
但是在构造c时我遇到了错误。我想做什么可能吗?
答案 0 :(得分:1)
普通绘图页面中的ContainingShape方法可能会返回页面本身(ID = 0),这不支持Characters对象。 Selection可以包含多个形状,但PrimaryItem属性将返回单个形状,如果Selection为空,则返回null / nothing。
所以你的代码应该是这样的:
Dim s As Visio.Shape
Dim c As Visio.Characters
Set s = ActiveWindow.Selection.PrimaryItem
If Not s Is Nothing Then
Set c = s.Characters
'Do something with characters
End If