如何在 Visio VBA 中获取命名形状的集合
我需要从活动页面上名为“CovIBox”的形状获取用户定义的整数值。
正确的方法是什么?
Private Function GetLastNumber() As Integer
''Need to get the last User Integer property of the shape "CovIBox"
''placed on the active page
Dim oPage As Visio.Page
Dim OColl As Collection
Dim intShapeVal As Integer
Dim IntHighest As Integer
Dim Ival As Integer
Set oPage = Application.ActiveWindow.Page
Set OColl = oPage.Shapes.Name("CovIBox") <----This where it fails
Ival = 0
For Each Shape In vsoCollection
Ival = Shape.CellsU("Prop.InterfaceNo").value
If Ival > IntHighest Then
IntHighest = Ival
End If
Next
Set OColl = Nothing
Set oPage = Nothing
GetLastNumber = IntHighest + 1
End Function
I need the get a user defined integer value from the shapes named "CovIBox" on the active page.
What is the correct method?
Private Function GetLastNumber() As Integer
''Need to get the last User Integer property of the shape "CovIBox"
''placed on the active page
Dim oPage As Visio.Page
Dim OColl As Collection
Dim intShapeVal As Integer
Dim IntHighest As Integer
Dim Ival As Integer
Set oPage = Application.ActiveWindow.Page
Set OColl = oPage.Shapes.Name("CovIBox") <----This where it fails
Ival = 0
For Each Shape In vsoCollection
Ival = Shape.CellsU("Prop.InterfaceNo").value
If Ival > IntHighest Then
IntHighest = Ival
End If
Next
Set OColl = Nothing
Set oPage = Nothing
GetLastNumber = IntHighest + 1
End Function
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Set OColl = oPage.Shapes.Name("CovIBox)
在 Visio 中,每个形状都有唯一的名称。您可以迭代每页的所有形状,检查它们的主名称并将感兴趣的形状收集到集合中
Set OColl = oPage.Shapes.Name("CovIBox)
In Visio each shape have unique name. You mast iterate all shapes per page, check their master name and collect intrested shape to collection