-2

I want to get the shape information out of a state (UML Standard Stencil). You can see in the picture the title "Aktiv" and "Eintritt/" etc. I have no clue where to get this as a variable.

UML example

Edit: To make it clear, I don't know how I can get the information out of a UML shape in Visio. Here is an example code:

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
piRSquared
  • 240,659
  • 38
  • 359
  • 510
Philipp Mochine
  • 3,205
  • 4
  • 26
  • 52
  • 5
    Hello and welcome to Stack Overflow, this is not a "code for me" website. Please provide evidences of your effort so we can assist you. I advise you to read the [ask] topic – Victor Moraes Jan 06 '17 at 15:01
  • Hey @victor-moraes, thank you for your comment. But sorry that I didn't explain it right. I don't want people to code for me. I just want to know what is the name of the method to get the information that I seek. My example code looks likes this (it really does not matter but you asked for it so:) Test – Philipp Mochine Jan 07 '17 at 07:51
  • Not sure if you tried to google it but [this seems like a start](https://msdn.microsoft.com/en-us/library/office/ff766497.aspx) – Victor Moraes Jan 07 '17 at 14:38
  • @VictorMoraes Thank you that helps but the most important part is to read out the "uppertitle" of the shape. I just get the "subtitle". – Philipp Mochine Jan 09 '17 at 07:37
  • As per your provided answer, it seems you have solved the issue :) – Victor Moraes Jan 09 '17 at 10:56

1 Answers1

0

Okay I found a solution, I don't know if there is a nicer one though.

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

with

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

So the state shape contains actually two shapes thus you can get the information from Item 1 or 2.

Philipp Mochine
  • 3,205
  • 4
  • 26
  • 52