我想从状态(UML Standard Stencil)中获取形状信息。你可以在图片中看到标题" Aktiv"和" Eintritt /"我不知道从哪里得到这个变量。
编辑: 为了说清楚,我不知道如何从Visio中的UML形状中获取信息。这是一个示例代码:
Private Sub test()
Dim s As Shape
Dim vsoPage As Visio.Page
Dim getStateName As String
'I need the name for example "Aktiv" from the state
'and the name of the "Sub" information as "Eintritt" etc.
Set vsoPage = ThisDocument.Pages(1)
For Each s In vsoPage.Shapes
getStateName = s.????
Next s
End Sub
答案 0 :(得分:0)
好的,我找到了一个解决方案,但我不知道是否有更好的解决方案。
Private Sub test()
Dim s As Shape
Dim vsoPage As Visio.Page
Dim getStateTitle As String
Dim getStateSubTitle As String
Set vsoPage = ThisDocument.Pages(1)
For Each s In vsoPage.Shapes
If Contains(s) = False Then
'Not a Stateshape
Else
getStateTitle = getStateTitle & s.Shapes.Item(1).Text & vbCrLf
getStateSubTitle = getStateSubTitle & s.Text & vbCrLf
End If
Next s
End Sub
与
Public Function Contains(s As Shape) As Boolean
Dim DummyString As String
On Error GoTo err
Contains = True
DummyString = s.Shapes.Item(1)
Exit Function
err:
Contains = False
End Function
因此状态形状实际上包含两个形状,因此您可以从第1项或第2项中获取信息。