Solved

Visio 2013 - Reposition Text handle - Where is it?

Posted on 2014-01-27
4
1,735 Views
Last Modified: 2014-02-03
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?
0
Comment
Question by:brothertruffle880
  • 2
4 Comments
 
LVL 30

Expert Comment

by:Scott Helmers
Comment Utility
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
0
 
LVL 11

Expert Comment

by:Visio_Guy
Comment Utility
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").
0
 

Author Comment

by:brothertruffle880
Comment Utility
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.
0
 
LVL 11

Accepted Solution

by:
Visio_Guy earned 500 total points
Comment Utility
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

0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

A recent Visio zone question asked how to use the data in an Excel file to create a Visio Gantt chart -- and then to dynamically update the Gantt chart. The good news is that the Viso Gantt Chart wizard can be automated. The bad news is that the…
David Parker’s latest book, Microsoft Visio 2010: Business Process Diagramming and Validation, will give you the tools to turn flowcharts and other business diagrams into valuable, data-driven corporate assets. Armed with the knowledge you’ll gain f…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now