Text Along a Connector’s Path in Microsoft Visio 2010

A feature lacking in Visio, like for-EVER, is the ability to align text along a connector’s path.
Now, Visio 2010′s new ShapeSheet functions and capabilities finally deliver.
Today we’ll show-off the cool new connector that I’ve developed for you, and get a very light technical explanation as to how it works!
In a previous post, I was re-creating (for fun!) a flowchart that I had seen in the Süddeutsche Zeitung.
In that flowchart, I needed to place connector-text along the actual line of the connector. Every time I adjusted the drawing, the angle of the connector changed, and I had to re-orient the text using the Text Block Tool.
You can see here how I am hastening the onset of arthritis with too much mousing:

Getting connector text to do this automatically is something I’ve wanted to implement for a long, long time. But the ShapeSheet couldn’t do it. I always needed to resort to code to get it to happen.
Today, however, I fired up my Visio 2010 beta and put some new features to work. The result is a connector that places text at the very end, rotated to match the angle of the last part of the connector.
No matter how many segments the connector has, what the terminal angle is, or the line-style, the text ends up in a reasonable position, and correctly aligned with the end:

Not bad, eh?
New ShapeSheet Capabilities Make it Possible!
Visio has added two new functions that I’ve used in two custom User-defined cells of the connector’s ShapeSheet. Take a gander:
User.angPathEnd = ANGLEALONGPATH( Geometry1.Path, 1 )
User.pntPathEnd = POINTALONGPATH( Geometry1.Path, 1 )
Not only do we have new functions in Visi0 2010, but we are able to refer to new types of objects. Up until now, we had to refer to ShapeSheet cells, and only ShapeSheet cells. But you can see that “Geometry1.Path” refers to a thing–a geometry section that is a group of cells. That’s new, and it’s pretty useful.
As you use an automatic connector in Visio, extra segments get added or removed from the connector. This has made it impossible to refer to the “last point” and “next-to-last point”, because ShapeSheet cells were being created and destroyed as the connector was reconfigured.
Now I can simply ask the ShapeSheet to tell me the angle along the path of “Geometry1.Path”, at 100% along the path’s lenght (that’s the “1″ you see in both functions)
Using similar syntax, I can ask for the end point too. The illustrated POINTALONGPATH function tells returns a Visio point-structure (combination of x- and y-values) for the point which is 100% of the way along Geometry1.Path.
This information was enough for me to relocated the shape’s text at the very end of the connector, offset and rotated correctly.
Bonus Features
Getting the text to be aligned at the end of the connector was fun. But I thought; “Hmm. That control handle that you can use to move text on Visio’s default connectors is also pretty cool!”
So I added a right-click context menu action to allow you to choose.
Notice the new, context Action menus that feature the fly-out, cascading items! You can read about these on John Goldsmith’s Custom Context Menus.

Here’s another look at the variations:

Have fun with this new connector. Note that this file uses new features available only in Visio 2010. while the file will likely open in Visio 2007 or Visio 2003, the shape won’t work as advertised.
If you don’t have Visio 2010, you might investigate getting a copy of the beta: Visio 2010 Beta: Sign Up Now!




Wow – one more reason I keep abusing Visio as a graphics program…
Doesn’t this functionality exist already in Visio 2007? I can position text on a connector by using the text block tool (click on the little down arrow on the text tool icon on the toolbar).
Don,
The angle of the text automatically matches that of the connector.
What you are referring to in previous versions of Visio was the ability to manually position the text somewhere along the connector. To do what I’ve created would require you to 1. move the text box and 2. rotated it to match the inclination of a portion of the connector.
The illustrations above look obvious and unimpressive because the behavior is natural and correct. But we really haven’t seen this possibility (without code) until now.
How do you get this connector to do the fancy zig-zag paths?
[...] Visio Guy reader posted a question at the end of Text Along a Connector’s Path in Microsoft Visio 2010, asking: “How do you get this connector to do the fancy zig-zag [...]
Hi DaveC,
Check out this article: Making Bends in Visio’s Dynamic Connector
Now if i could get this for text at both ends at the same time, that would be perfect.
Jeremy,
a cludgy but effective solution would be to create two connectors between your objects, one in each direction.
Of course two connectors would look pretty silly if they followed different routes between the objects, so only really useful for straight connectors.
This looks like it could solve a few problems for me. Many thanks.
Great, it is exactly what I was looking for !
But really, really why it isn’t built in Visio 2010 ??
Really wired.
Then Chris,
to be complete how easily you could add the sub-menus :
Along connector at Middle
Along connector at Beginning
Pierre,
I don’t understand your question. It IS built in Visio 2010, and could only be built in Visio 2010, because it uses new ShapeSheet functions.
Of course I could add the other functions, but so could you!
Thanks for the ideas.
Chris
Well, I must have missed something.
The fact is that I’m very disturbed by the Visio 2010 ribbon interface.
I found how to rotate the text manually along the connector but not how to have the text of the arrow follow automatically its direction !
Pierre
Hi Pierre,
It isn’t an easy thing to do. The point of this article is to show that it *can* be done. It requires using Visio’s ShapeSheet, something that takes a while to learn.
I have considered making a more advanced shape, but is probably something that I will have to create for sale because I don’t have a lot time these days for give-aways.
Thanks for visiting the site and asking questions, by the way!
Chris
I understand better now
So the question is still open :
Why it isn’t built into Visio 2010 ?
Pierre
I think Visio has to tread a fine line between general-purpose and special-purpose. With Visio 2010 (Premium), they’ve added a lot of process-specific stuff. This will help a lot of people, but it could get in the way of non-process diagramming folks and third party solutions. The Visio universe is tricky because it is so huge.
I am using Visio 2003 SP3 and thought I would try it and it works perfectly.
Hi CEC,
You may be getting lucky, or just aren’t noticing what the feature is intended to do. This should definitely NOT work properly in Visio 2003!
Hello,
In the early versions (around 2000), one could add a text box around the text on the connector. Does anyone know how to do this in 2007? Is it even possible?
Hi Barbara,
Do you mean add an outline around the text box, or just a background fill? You can still add a background color to any text block via the Format > Text dialog. Go to the “Text Block” tab and look for the “Text background” setting.
Hi Visio Guy,
I can add the background color, but I’d really prefer an outline around the text. The alternative would be to move the text box closer to the connector and shape location which I just learned how to do. I have a diagram with many lines, and the text boxes tend to overlap.
Thanks for the tips on other questions. I just discovered this site this morning, and it seems to be a good source for help. Microsoft On-line is too general.
Hi,
I’m trying to adapt your shapesheet definition to Add “Along Connector at StartArrow” and “Centered Along Connector” … but i don’t undesrand how works Visio function…
there is no one who has already done this?
Thanks in advance…
Hi G,
It involves some ShapeSheet work. First, for the middle of the connector. First add this cell and formula:
User.pathFraction = IF(User.txtState=1,1,IF(User.txtState=2,0.5,0))
Now, modify two existing cells:
User.angPathEnd = ANGLEALONGPATH(Geometry1.Path, User.pathFraction)
User.pntPathEnd = POINTALONGPATH(Geometry1.Path, User.pathFraction)
These cells are now more general, and should actually be renamed User.angPath and User.pntPath, since they will soon for both the end and the midpoints.
Add a new Actions row, name it Actions.TextAtMid, then set these formulas:
Actions.TextAtMid.Menu = “At Connector Mid-point”
Actions.TextAtMid.Checked = User.txtState=2
Actions.TextAtMid.Action = SETF(GetRef(TxtPinX),”GUARD(User.TextPin)”)+
SETF(GetRef(TxtPinY),”GUARD(User.TextPin)”) +
SETF(GetRef(TxtAngle),”User.TextAngle”) +
SETF(GetRef(Controls.TextPosition.YCon),5) +
SETF(GetRef(User.txtState),2)
Actions.TextAtMid.FlyoutChild = True
Remember this only works for Visio 2010 as of this writing. Older versions don’t support these ShapeSheet functions.
Thanks a lot Mr. Visio Guy
Hu,
Is it possible to center text on middle of connector? :s
I know I’m exigent… but it’s so pleasant to have text on middle of connector…
And so, you’ll be able to update your attachment with differents examples :p
Hi,
I have the same question as guest before me. Is it possible to center text on middle of connector?
I try to fix it for 5 days, and without luck.
Is it possible, to have text box on both sides?
Thanks
BR Bozo
Hi Bozo,
If you’re talking about this connector–the download that accompanies this article–then yes.
As it says in the article, just right-click and choose “Text Orientation > Position by Control Handle”. You can then move the control handle to the center of the connector – just pull on the yellow diamond handle.
For regular Visio connectors, the control handle is always there.
In either case, you don’t need to use the Text or Text Block tools. The control handles save you the trouble!