• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Visio Guy

Smart graphics for visual people




  • Home
  • Hire Me
    • Hire Me
    • Résumé
  • Products
    • Products
    • Bubble Revision Shape
    • Layers to Pages Utility
    • Rack Unit Dimension Line
    • Radial Elements Tool with up to 100 Wedges
    • Text on a Circle Visio SmartShape
  • Index
    • Articles by Date
    • YouTube – VisioGuy
    • Download Information
    • Suggestion Box
    • Shop
    • Visio Art
    • Visio Links
    • – Visio Shapes & Stencils
    • – Visio Templates & Drawings
  • About
    • About
    • Donate
    • GitHub
    • jsFiddle
    • Reading List
    • Subscribe & Follow
      • – E-mail
      • – facebook
      • – Twitter
      • – RSS
    • Privacy Policy
  • Discussion Forum
You are here: Home / Development / Code / Text to the Bottom of the Shape

Text to the Bottom of the Shape

November 7, 2007 By Visio Guy 5 Comments

A Visio newsgrouper recently pointed out that in Visio, inserted images have a different default text position than normal shapes. For images, the text is located at the bottom of the shape, and text “grows” downward.

This makes sense, since you usually don’t want the text to obscure the image. But perhaps you shape developers out there in Internet Land might wish to have the same text behavior for your shapes!

In this article, we’ll discuss how to do it by hand, and offer some VBA script to get the job done faster!

Default Text Positions

Let’s first take a quick look at what we’re talking about. In Visio, when you insert an image, draw a shape, or create a group, the default text positions look like this.

Text To Bottom - DefaultPositions

It’s easy to see that the inserted-image at left has a different default text block!

Move it Manually

We can get ordinary Visio shapes to behave just like the inserted images. To adjust your shape-text to act like the images, just do the following:

  1. Select the Text Block Tool from underneath the Text Tool on the StandardToolbar:Text To Bottom - Text Block Tool
  2. Select your shape
  3. Drag the top-edge of the green rectangle all the way to the bottom
  4. Set the text alignment to”Top” using the Align Top toolbar button:Text To Bottom - Align Top

You’re done! Your text should now be located at the bottom of the shape, and should grow downwards, away from the shape as you type more text.

The Text Block Tool is handy for adjusting the size, position and angle of the text on any Visio shape!

Quicker With Code

Of course, for us developer-oriented folks, that’s way too much work. Here’s some VBA code to get the job done more quickly.

To get this to run, do the following:

  1. Paste this code into the VBA project of a Visio document
  2. Select some shapes in the Visio drawing window
  3. Run the code from the VBA editor, by putting your cursor inside the Sub and hitting F5
    – or –
    Run the code from the drawing page by selecting from the menu: Tools > Macros > ThisDocument > QuickTextToBottom

Here’s the code-listing:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Sub QuickTextToBottom()
 
  '// 2007.11.07
  '// Visio Guy
  '//
  '// Adjusts the text block of selected shapes so that
  '// the text is at the bottom of the shape. This matches
  '// the default text position for inserted images.
 
  Dim sel As Visio.Selection
  Dim shp As Visio.Shape
  Set sel = Visio.ActiveWindow.Selection
 
  For Each shp In sel
 
    '// 'Add' the Text Transfomrm section, if it's not there:
    If Not (shp.RowExists(Visio.VisSectionIndices.visSectionObject, _
          Visio.VisRowIndices.visRowTextXForm, _
          Visio.VisExistsFlags.visExistsAnywhere)) Then
 
    Call shp.AddRow(Visio.VisSectionIndices.visSectionObject, _
          Visio.VisRowIndices.visRowTextXForm, _
          Visio.VisRowTags.visTagDefault)
 
    End If
 
    '// Set the text transform formulas:
    shp.CellsU("TxtHeight").FormulaForceU = "Height*0"
    shp.CellsU("TxtPinY").FormulaForceU = "Height*0"
 
    '// Set the paragraph alignment formula:
    shp.CellsU("VerticalAlign").FormulaForceU = "0"
 
  Next shp
 
End Sub
Sub QuickTextToBottom()
 
  '// 2007.11.07
  '// Visio Guy
  '//
  '// Adjusts the text block of selected shapes so that
  '// the text is at the bottom of the shape. This matches
  '// the default text position for inserted images.
 
  Dim sel As Visio.Selection
  Dim shp As Visio.Shape
  Set sel = Visio.ActiveWindow.Selection
 
  For Each shp In sel
 
    '// 'Add' the Text Transfomrm section, if it's not there:
    If Not (shp.RowExists(Visio.VisSectionIndices.visSectionObject, _
          Visio.VisRowIndices.visRowTextXForm, _
          Visio.VisExistsFlags.visExistsAnywhere)) Then
 
    Call shp.AddRow(Visio.VisSectionIndices.visSectionObject, _
          Visio.VisRowIndices.visRowTextXForm, _
          Visio.VisRowTags.visTagDefault)
 
    End If

    '// Set the text transform formulas:
    shp.CellsU("TxtHeight").FormulaForceU = "Height*0"
    shp.CellsU("TxtPinY").FormulaForceU = "Height*0"
 
    '// Set the paragraph alignment formula:
    shp.CellsU("VerticalAlign").FormulaForceU = "0"
 
  Next shp

End Sub
  • Tweet
  • More
  • Pocket
  • Share on Tumblr
  • Print
  • Email

Related posts:

  1. The Hidden World of Visio Shapes
  2. Circular Text Generator (version 1)
  3. Customized Visio HTML Export
  4. European Cup 2008 Auto-Updating Visio Diagram (v2)
  5. Visio Nerd Videos – For Developers!

Filed Under: Code, Development, ShapeSheet Tagged With: Code, Images, Programming, Text

Previous Post: « Oblique Connectors For Your 3D Diagrams
Next Post: Visio for Fashion Design? »

Reader Interactions

Comments

  1. Jason says

    April 23, 2008 at 5:04 pm

    What can I say but, “Thank you! Thank you! Thank you!” It was killing me trying to figure out how to do this. The simpler the solution, the harder it is to find sometimes.

    Thank you again! I truly appreciate your posts here!
    Jason

  2. Jill G. says

    February 19, 2009 at 10:07 pm

    YAY thank you! Not sure why Visio makes things so difficult and does not center/middle text like it should, but this is just the trick I needed.

  3. Visio Guy says

    February 19, 2009 at 11:54 pm

    Glad you’re happy, but not sure what you mean? Visio text IS center-middle by default.

    I think a lot of complaints about Visio come because it can be used for so many different types of drawing, whereas other apps excel at just a few.

    Anyway, happy to help you solve your problem!

    – Chris

  4. Bynez says

    September 28, 2012 at 3:32 pm

    Thanks, that was very helpful, I had been fighting with textblock alignment for a while.

  5. Matthew Bickford says

    June 29, 2015 at 3:40 pm

    How do I make the wording look realistic on an image (for example – the computer monitor image) so that t doesn’t look like it is leaning at weird angles on the screen of the image? New to Visio

Leave a Reply Cancel reply

Primary Sidebar

Buy Text on a Circle Shape
Article — Video — Purchase

Categories

Buy my book!

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Tag Cloud

A/V Artistic Effects BPM Code Connectors Control Handles Countries Custom Patterns Custom Properties Data Graphics Data Linking Data Visualization David Edson David Parker Fill Format Formulas Functions Geometry Gradient Images Links Maps Multi-shapes Network Programming repeating shapes Resources Right-Click Actions Scale Shape Data ShapeSheet ShapeSheet Formulas ShapeSheet Functions SharePoint shiny SmartShapes Sport Sports Text Themes Tools Transparency User-defined Cells Visio 2007 Visio SmartShapes

Top Posts & Pages

  • - Visio Shapes & Stencils
  • - Visio Templates & Drawings
  • Bubble Revision Shapes
  • Sankey Diagram Shapes for Visio
  • Visio Network Server Shape Icon Customization Tool
  • Amazon AWS Visio Shapes
  • Go 3D with Free Isometric Piping Shapes for Visio
  • Dynamic Updating Org Charts in Visio!
  • Text to the Bottom of the Shape
  • Map of World

www.visguy.com - Visio Guy - since 2006

 

Loading Comments...