list all connections and endpoints

R

revans00

Hello,

I have an existing Visio (2002) drawing with several shapes (rectangles)
connected by line (Dynamic connectors). I would like to extract a simple
text list for each Dynamic connector, the name (actual object text
label) of the rectangles on either end.

I've created some code which does walk through the shapes in the
activepage, and have tried to use some sample code from various sources
(ie: http://visio.mvps.org/VBA.htm), but can't quite get it to work.

Can anyone help please?

TIA!
Richard

Public Sub ListObjs()

'Declare object variables as Visio object types.
Dim intCounter As Integer
Dim intShapeCounter As Integer
Dim vsoPage As Visio.Page
Dim vsoDocument As Visio.Document
Dim vsoDocuments As Visio.Documents
Dim vsoPages As Visio.Pages
Dim vsoShapes As Visio.Shapes
Dim vsoShape As Visio.Shape
Dim groupedShapes As Visio.Shape
Dim vsoConnects As Visio.Connects
Dim vsoConnect As Visio.Connect
Dim vsoConnectToCell As Visio.Cell
Dim i As Integer
Dim PosX As Double, PosY As Double
Dim ShapeX As Double, ShapeY As Double


' Set vsoShapes = ActivePage.Shapes
Set vsoShapes = ActiveDocument.Pages.Item(1).Shapes

For intShapeCounter = 1 To vsoShapes.Count


' This code seems to get me closer, but not close enough!
'Get the next shape.
Set vsoShape = vsoShapes.Item(intShapeCounter)
Set vsoConnects = vsoShape.Connects
Debug.Print "Name: "; vsoShape.Name
Debug.Print "ID : "; vsoShape.ID
Debug.Print "Type: "; vsoShape.Type
If vsoShape.CellExists("Prop.Row_1.Label", 1) Then
Debug.Print "Val : ";
vsoShape.Cells("Prop.Row_1.Value").ResultStr(0)
Debug.Print "Val : ";
vsoShape.Cells("Prop.Row_2.Value").ResultStr(0)
End If

'For each connection, get the cell it connects to.
For intCounter = 1 To vsoConnects.Count

Set vsoConnect = vsoConnects(intCounter)
Set vsoConnectToCell = vsoConnect.ToCell

'Print connect information in the Immediate window.
Debug.Print " To "; vsoConnectToCell.LocalName

Next intCounter

' This code didn't give me results that looked valuable
' Set vsoShape = Visio.ActivePage.Shapes(intShapeCounter)
' nrows = vsoShape.RowCount(Visio.visSectionConnectionPts)
' Debug.Print "#"; intShapeCounter; " "; vsoShape.Name; "
connections ="; nrows
' If nrows > 0 Then
' ShapeX = vsoShape.CellsSRC(Visio.visSectionObject,
visRowXFormOut, visXFormPinX).Result(Visio.visNone)
' ShapeX = ShapeX - vsoShape.CellsSRC(Visio.visSectionObject,
visRowXFormOut, visXFormLocPinX).Result(Visio.visNone)
' ShapeY = vsoShape.CellsSRC(Visio.visSectionObject,
visRowXFormOut, visXFormPinY).Result(Visio.visNone)
' ShapeY = ShapeY - vsoShape.CellsSRC(Visio.visSectionObject,
visRowXFormOut, visXFormLocPinY).Result(Visio.visNone)
' For i = 0 To nrows - 1
' PosX = ShapeX +
vsoShape.CellsSRC(Visio.visSectionConnectionPts, i,
visX).Result(Visio.visNone)
' PosY = ShapeY +
vsoShape.CellsSRC(Visio.visSectionConnectionPts, i,
visY).Result(Visio.visNone)
' Debug.Print PosX; " "; PosY
' Next i
' End If


Next intShapeCounter
 
M

Markus Breugst

Did you find my sample code? I posted it some time ago and I guess it could
help you.

Please use google groups to look for:

visio "examining connections"

Best regards,
Markus
 
R

revans00

JuneTheSecond said:
Connect object might be your help.
Hi JuneTheSecond,

I suspect you are right, but I lack the experience to actually know
"how". May I please ask if you have any specific code or other examples
that I can use?

Thanks!
Richard
 
R

revans00

Hi Markus,

Thanks for the reply! I did google as you suggest and got three hits.
The first hit took me to tech-archive.net where I found some postings of
yours relating to saving selected selected shapes as a jpg and another
about stopping shapes being plowed off page. Unfortunately I don't see
code there for connections.

The second link is a job posting

The third link takes me to "OfficeHelp" which looks promising, but I
don't see anything there either.

Thanks!
Richard
 
J

JuneTheSecond

You might find examples in the code librarian of Visio2003 SDK.
One of the key words to find might be "connects".
 

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