I found the Visio Guy article for having a connector's text follow the connector.
http://www.visguy.com/2010/02/09/text-along-a-connectors-path-in-microsoft-visio-2010/I am using Visio 2013 Professional along with the shapesheet code provided by Ilya Kharlamov (posted on 10/14/2012 in the comments section of the article).
User.angPathEnd=ANGLEALONGPATH(Geometry1.Path,User.pathFraction)
User.pntPathEnd=POINTALONGPATH(Geometry1.Path,User.pathFraction)
User.TextAngle=User.angPathEnd+GRAVITY(User.angPathEnd)
User.TextPin=PNT(PNTX(User.pntPathEnd)-TxtLocPinX*COS(User.angPathEnd),PNTY(User.pntPathEnd)-TxtLocPinX*SIN(User.angPathEnd))
User.txtState=2
User.pathFraction==((User.txtState-1)/2)+((1-((User.txtState-1)/2))*TxtWidth/PATHLENGTH(Geometry1.Path))
Action.Row_1.Action=""
Action.Row_1.Menu="Text Orientation"
Action.Row_2.Action=SETF(GetRef(TxtPinX),"SETATREF(Controls.TextPosition)")+SETF(GetRef(TxtPinY),"SETATREF(Controls.TextPosition.Y)")+SETF(GetRef(TxtAngle),0)+SETF(GetRef(Controls.TextPosition.YCon),0)+SETF(GetRef(User.txtState),0)
Action.Row_2.Menu="Position by Control Handle"
Action.Row_2.Checked=User.txtState=0
Action.Row_3.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),1)+SETF(GetRef(Para.HorzAlign),User.txtState-1)
Action.Row_3.Menu="Start"
Action.Row_3.Checked=User.txtState=1
Action.Row_4.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)+SETF(GetRef(Para.HorzAlign),User.txtState-1)
Action.Row_4.Menu="Mid"
Action.Row_4.Checked=User.txtState=2
Action.Row_5.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),3)+SETF(GetRef(Para.HorzAlign),User.txtState-1)
Action.Row_5.Menu="End"
Action.Row_5.Checked=User.txtState=3
The code works perfectly and the connectors behave as expected until I save/close the file and open it again. When I open the Visio file, sometimes a connector' text will be just fine and sometimes the text be in a different part of the diagram, or even hidden. I have a diagram with ~40 of these connectors, created from the same master, and they seem to behave differently each time I open the Visio document.
If I make a change to one of the problem connectors (move, disconnect, reconnect), then the text repositions itself to the proper location again and all is well until I close and reopen the file. Then I have to go through each problem connector and modify it in some way to get the text to behave again.
NOTE: I tried the two solutions provided by Visio Guy in his article and I get the same behavior.
So here are my questions:
Is this happening because of a flaw in the code, or because of a bug in Visio 2013?
Is there a way to protect (lock) the position of the text to prevent this from happening?
Does anyone have any other suggestions on how to get the text position to be reliable when reopening the file?
Thank you!