forcing connection paths from VBA

B

BramBsr

I'm developing a Visio program that stores information about a process into
an MSAccess database. One of the aspects of the process that's stored is
which activiteis are connected. The main Visio diagram is generic and based
on user input, information is read from the database and certain activies'
attributes are changed/displayed (colour, text, etc.) and connected to other
activities. My problem is getting the connection lines to go where I want
them to. I use the Drop method to drop a connection in the page and then two
GlueTo methods to connect it to the start and end activities. Each time I do
this, I have to manually re-route the connection lines to make them look
reasonable, especially with a complex process with many connections. I've
tried to save the data from the Geometry1 section of the ShapeSheet into the
database (that works OK), but when I try to write that information back to
the ShapeSheet afterwards, nothing happens. Here's the code I'm using to try
to adjust t he line routing:

Set objConnector = ActivePage.Drop(myConn, 0, 0)
Call
objConnector.CellsU("BeginX").GlueTo(ActivePage.Shapes("Rectangle." &
Trim(Str(rstProcess.Fields("OrigAct")))).Cells("PinX"))
Call
objConnector.CellsU("EndX").GlueTo(ActivePage.Shapes("Rectangle." &
Trim(Str(rstProcess.Fields("DestAct")))).Cells("PinX"))

strSQL = "SELECT tblFlowDetails.FlowID, tblFlowDetails.PointID,
tblFlowDetails.X_Pos, tblFlowDetails.Y_Pos"
strSQL = strSQL & " FROM tblFlowDetails"
strSQL = strSQL & " WHERE (((tblFlowDetails.FlowID) = " &
rstProcess.Fields("FlowID") & "))"
strSQL = strSQL & " WITH OWNERACCESS OPTION;"
Set rstFlowDetail = myDataBase.OpenRecordset(strSQL)

rstFlowDetail.MoveLast
rstFlowDetail.MoveFirst

For I = 1 To rstFlowDetail.RecordCount
objConnector.Cells("Geometry1.X" & Trim(Str(I))).Formula =
rstFlowDetail.Fields("X_Pos")
objConnector.Cells("Geometry1.Y" & Trim(Str(I))).Formula =
rstFlowDetail.Fields("Y_Pos")
rstFlowDetail.MoveNext
Next I

I know I'm something simple wrong and I have searched many hours for some
examples to help me to get this to work. Any suggestions would be much
appreciated.
 
M

Mark Nelson [MS]

I'd be interested to know why you must go to the trouble of storing and
reconstructing connector paths. Do you have special requirements for the
routing of connectors, or do you feel that Visio is not routing the
connectors sensibly? Is there a different routing style you could use to
get the desired results?

In your code below, I don't see any code to insert the necessary Shapesheet
rows in the Geometry section of the connector. A connector that has just
been dropped will only have a couple rows in the section. Your code needs
to add more.

--
Mark Nelson
Office Graphics - Visio
Microsoft Corporation

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

BramBsr

The diagram is a process flowchart that uses the "Swimlane" approach to group
related activities in horizontal lanes. When connectors cross lanes, Visio
tries to route them to the outside of the page and then back in again,
causing many more legs than required. I've tried deleting all the rows
eccept row 0 in the geometry1 section of the shapesheet and then adding them
again, but that did not work either. Is there a way to have Visio ignore the
shapes I'm using to create the swimlanes so that it doesn't try to route
connectors around them?

Thanks for your help.
 
M

Mark Nelson [MS]

Are you using Visio's built-in shapes for Functional Bands or your own? I
have not seen this under normal circumstances. You might try selecting the
bands and choosing Format > Behavior > Placement to set the Placement
Behavior to "Do not layout and route around".

There are some other things to try with connector routing. This article
explains some of the tricks:
http://blogs.msdn.com/visio/archive/2006/09/15/756352.aspx

--
Mark Nelson
Office Graphics - Visio
Microsoft Corporation

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

BramBsr

OK, that worked. I had tried something like that before, but with all the
bands in a Group. Once I ungrouped them and changed each behaviour property
individually, the automatic routing works much better.

Thanks
 

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