If you watch the formulas of the connector when being inclined, horizontal or vertical, you'll notice that the formulas for width and height change.
Inclined and horizontal:
width = GUARD(EndX-BeginX)
height = GUARD(5 mm)
Vertical:
width = GUARD(5 mm)
height = GUARD(EndX-BeginX)
Odd enough, it has probably something to do with the way Visio calculates the length.
I also don't know where the 5mm come from. It seems to be neither the grid spacing nor the size of the sub-shape.
Anyway, how to find the right point for the different inclinations of the connector?
I helped myself with a control point, set it to (0,0) and (1,1) and observed that it jumps like the sub-shape does.
So I corrected manually the position of the control point to get the coordinates for the rectangle.
Ending up for the sub-shape with the formulas
PinX = IF(Sheet.1!BeginX=Sheet.1!EndX,Sheet.1!Width*0.5,Sheet.1!Width*1)
PinY = IF(Sheet.1!BeginY=Sheet.1!EndY,Sheet.1!Height*0.5,Sheet.1!Height*1)
for the end point
respectively
PinX = IF(Sheet.1!BeginX=Sheet.1!EndX,Sheet.1!Width*0.5,0)
PinY = IF(Sheet.1!BeginY=Sheet.1!EndY,Sheet.1!Height*0.5,0)
for the begin point
----
Later I checked the links Wapperdude provided, specially the one from John Goldsmith.
He uses an intermediate field with a POINTALONGPATH formula. Certainly a more elegant way, since you can place the label "on" the connector at "any" place.