How do I get the NameU of a Connect object in Visio?

  • Thread starter Connect Object NameU
  • Start date
C

Connect Object NameU

I have constructed template with a stencil whose shapes and connectors have
master names.
The intent is to represent a relational structure in which the connector
master names are the relationship types and the shape master names are the
object types.
When a connection is made between two shapes in a document opnened with this
template, a corresponding relation is asserted between the objects. I need to
establish whether that assertion is 'valid'.
To do this, I need to match the triple (FromObjectNameU, ConnectObjectNameU,
ToObjectNameU) is in a table of valid relations.
 
A

Al Edlund

this from the v2003 sdk library
' Copyright (c) Microsoft Corporation. All rights reserved.

Public Sub ShowPageConnections(vsoPage As Visio.Page)

' ShowPageConnections
'
' Abstract - This procedure walks the connections of the
' Page passed in and displays the information about the
' connectors.
'
' Parameters
' vsoPage The Page whose connections will be walked

Dim vsoShapeFrom As Visio.shape
Dim vsoShapeTo As Visio.shape
Dim vsoConnects As Visio.Connects
Dim vsoConnect As Visio.Connect
Dim vsoFromData As Visio.VisFromParts
Dim vsoToData As Visio.VisToParts
Dim intFromData As Integer
Dim intToData As Integer
Dim strFrom As String
Dim strTo As String

On Error GoTo ShowPageConnections_Err

' Get the Connects collection for the page.
Set vsoConnects = vsoPage.Connects

' Loop through the Connects collection.
For Each vsoConnect In vsoConnects

' Get the From information.
' Use intFromData to determine the type of connection.
Set vsoShapeFrom = vsoConnect.FromSheet
intFromData = vsoConnect.FromPart

If (intFromData < VisFromParts.visControlPoint) Then

strFrom = vsoConnect.FromCell.Name

Else
' Converts the VisFromParts value to a string.
' Control points are numbered starting with 1
' in the UI but with 0 in the API.
strFrom = "visControlPoint" _
& CStr(intFromData - visControlPoint + 1)
End If

' Get the To information.
' Use intToData to determine the type of shape to
' which the connector is connected.
Set vsoShapeTo = vsoConnect.ToSheet
intToData = vsoConnect.ToPart

If (intToData < VisToParts.visConnectionPoint) Then

strFrom = vsoConnect.ToCell.Name

Else
' Converts the VisToParts value to a string.
' Connection points are numbered starting with 1
' in the UI but with 0 in the API
strTo = "visConnectionPoint" _
& CStr(intToData - visConnectionPoint + 1)

End If

' Display the information in the Debug window.

Debug.Print strFrom & " of " _
& "'" & vsoShapeFrom.Name & "'" _
& " is connected to " & strTo & " of " _
& "'" & vsoShapeTo.Name _
& "'" & " with Text: " & "'" _
& vsoConnect.FromCell.shape.Text & "'"
Next

Exit Sub

ShowPageConnections_Err:
Debug.Print Err.Description

End Sub

al
 
C

Connect Object NameU

I've seen that already.
I doesn't answer my question.
Given a Connect object in a document opened from a template, I need to get
the name of its master in the template's stencil.
Any more ideas?
 
M

Mark Nelson [MS]

A Connect object is not a shape; it is a glued connection between two
shapes. Those shapes are identified by the FromSheet and ToSheet
properties. The FromSheet will always be the 1-D connector and the ToSheet
will always by the 2-D shape. Once you have shape objects you can use the
Master property to get a reference to their master. Then you can get the
NameU property from the master object.

--
Mark Nelson
Office Graphics - Visio
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top