Visio 2013 - Reposition Text handle - Where is it?

I am using a stencil and after I entered text I saw there was no "reposition text handle"  I don't think this stencil has one.  How can I create one for this shape?
Who is Participating?
Visio_GuyConnect With a Mentor Commented:
Hi BT,

I put this code in a stencil, and save the stencil in My Shapes. Then I can get to it easily via More Shapes.

You still have to open the VBA editor (Alt + F11) to run it, but it's super easy to do.

Just select a shape or shapes in a drawing window or master-editing window, then place the cursor in one of the "Sub AddTextRepositionControlHandleToSelection_" procedures and hit F5. Boom! You've got control-handle text!

Option Explicit

'// Module: ControlHandleText
'// Last Edit: 2010.05.17
'// Procedures for adding the default control-handle-positioned
'// text to a selection of shape.
'// Includes the SETREF behavior to handle users moving the text
'// block using the Text Block Tool, and hiding the control handle
'// when the shape has no text or HideText is true.

Private Const TextChCellName$ = "Controls.vgRepositionText"
Private Const TextChRowName$ = "vgRepositionText"

Private Const DefTextPosX_Left% = 0
Private Const DefTextPosX_Center% = 1
Private Const DefTextPosX_Right% = 2

Private Const DefTextPosY_Bottom% = 0
Private Const DefTextPosY_Middle% = 1
Private Const DefTextPosY_Top% = 2

'// Bottom-left:
Sub AddTextRepositionControlHandleToSelection_BottomLeft()
    Call m_iterateSelection(DefTextPosX_Left, DefTextPosY_Bottom)
End Sub
'// Bottom-center:
Sub AddTextRepositionControlHandleToSelection_CenterBottom()
    Call m_iterateSelection(DefTextPosX_Center, DefTextPosY_Bottom)
End Sub
'// Bottom-right:
Sub AddTextRepositionControlHandleToSelection_RightBottom()
    Call m_iterateSelection(DefTextPosX_Right, DefTextPosY_Bottom)
End Sub
'// Middle-left:
Sub AddTextRepositionControlHandleToSelection_LeftMiddle()
    Call m_iterateSelection(DefTextPosX_Left, DefTextPosY_Middle)
End Sub
'// Middle-right:
Sub AddTextRepositionControlHandleToSelection_RightMiddle()
    Call m_iterateSelection(DefTextPosX_Right, DefTextPosY_Middle)
End Sub
'// Top-left:
Sub AddTextRepositionControlHandleToSelection_TopLeft()
    Call m_iterateSelection(DefTextPosX_Left, DefTextPosY_Top)
End Sub
'// Top-right:
Sub AddTextRepositionControlHandleToSelection_TopRight()
    Call m_iterateSelection(DefTextPosX_Right, DefTextPosY_Top)
End Sub
'// Middle-center:
Sub AddTextRepositionControlHandleToSelection_CenterMiddle()
    Call m_iterateSelection(DefTextPosX_Center, DefTextPosY_Middle)
End Sub

Sub AddResetTextPositionAction()

  Const ResetTextActionLabel$ = "Reset Text Position"
  Const ResetTextActionRowName$ = "vgResetTextCH"
  Dim shp As Visio.Shape
  Dim r As Visio.Row
  Dim fDefaultX As String, fDefaultY As String
  For Each shp In Visio.ActiveWindow.Selection
    If (shp.CellExists(TextChCellName, Visio.VisExistsFlags.visExistsAnywhere)) Then
      Set r = ShapeUtils.GetOrAddActionRow(shp, ResetTextActionLabel, ResetTextActionRowName)
      fDefaultX = shp.Cells(TextChCellName).Formula
      fDefaultY = shp.Cells(TextChCellName & ".Y").Formula
      r(Visio.VisCellIndices.visActionMenu).Formula = Chr(34) & ResetTextActionLabel$ & Chr(34)
      r(Visio.VisCellIndices.visActionDisabled).Formula = _
        "AND((" & fDefaultX & ")=" & TextChCellName & ",(" & fDefaultY & ")=" & TextChCellName & ".Y)"
      r(Visio.VisCellIndices.visActionAction).Formula = "SETF(GETREF(" & TextChCellName & ")," & _
        Chr(34) & fDefaultX & Chr(34) & ")+SETF(GETREF(" & TextChCellName & ".Y)," & Chr(34) & fDefaultY & Chr(34) & ")"
      r(Visio.VisCellIndices.visActionSortKey).Formula = Chr(34) & "CheckState200" & Chr(34)
      r(Visio.VisCellIndices.visActionBeginGroup).ResultIU = 1
    End If
  Next shp
End Sub

Private Sub m_iterateSelection(ByVal defaultXpos As Integer, _
                               ByVal defaultYpos As Integer)

    Dim shp As Visio.Shape
    For Each shp In Visio.ActiveWindow.Selection
      Call m_addControlHandleText(shp, defaultXpos, defaultYpos)

    Next shp
End Sub
Private Sub m_addControlHandleText(ByRef shp As Visio.Shape, _
                                   ByVal defaultXpos As Integer, _
                                   ByVal defaultYpos As Integer)
  Dim visRow As Visio.Row
  Set visRow = ShapeUtils.GetOrAddControlHandleRow(shp, TextChRowName$)
  shp.Cells("TxtWidth").FormulaForceU = "GUARD(TEXTWIDTH(TheText))"
  shp.Cells("TxtHeight").FormulaForceU = "GUARD(TEXTHEIGHT(TheText,TxtWidth))"
  shp.Cells("TxtPinX").FormulaForceU = "SETATREF(" & TextChCellName & ".X)"
  shp.Cells("TxtPinY").FormulaForceU = "SETATREF(" & TextChCellName & ".Y)"
  shp.Cells("TxtLocPinX").FormulaForceU = "GUARD(TxtWidth*0.5)"
  shp.Cells("TxtLocPinY").FormulaForceU = "GUARD(TxtHeight*0.5)"
  Dim c As Visio.Cell
  Set c = visRow(Visio.VisCellIndices.visCtlX)
  Select Case defaultXpos
  Case 0
    c.FormulaForce = "-TxtWidth*0.5"
  Case 1
    c.FormulaForce = "Width*0.5"
  Case 2
    c.FormulaForce = "Width + TxtWidth*0.5"
  End Select
  Set c = visRow(Visio.VisCellIndices.visCtlY)
  Select Case defaultYpos
  Case 0
    c.FormulaForce = "-TxtHeight*0.5"
  Case 1
    c.FormulaForce = "Height*0.5"
  Case 2
    c.FormulaForce = "Height + TxtHeight*0.5"
  End Select
  Set c = visRow(Visio.VisCellIndices.visCtlTip)
  c.FormulaForce = Chr(34) & "Reposition Text" & Chr(34)
  Set c = visRow(Visio.VisCellIndices.visCtlGlue)
  c.FormulaForce = "FALSE"
  Set c = visRow(Visio.VisCellIndices.visCtlXCon)
  c.FormulaForce = "5*OR(HideText,STRSAME(SHAPETEXT(TheText)," & Chr(34) & Chr(34) & "))"
End Sub

Open in new window

Scott HelmersVisio Consultant, Trainer, Author, and DeveloperCommented:
Unless the text block has been locked, you can manipulate it with the text block tool. Simply select the tool, then click the shape: any moves or changes you make affect the text block and not the underlying shape.text block
FYI: The control-handle-text is a nicety built into some shapes, but not all of them. Networking shapes have it (although it is partially broken in Visio 2013), flowchart shapes don't (since the text usually lives "inside the box").
brothertruffle880Author Commented:
Is there any way for me to add the control-handle-text to my custom-built shapes?  I really like them and I want to place them into my own custom-built shapes.
That's my ultimate goal in asking.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.