• Categories

  • Archives

  • Subscribe

  • Meta

Text to the Bottom of the Shape

Posted by Visio Guy on November 7th, 2007 2274 views

Read Full ArticleA 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:

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

Share this article!

These icons link to social bookmarking sites where readers can share and discover new web pages.

  • StumbleUpon
  • Digg
  • del.icio.us
  • Technorati
  • YahooMyWeb
  • Slashdot

Related Posts:

One Response to “Text to the Bottom of the Shape”

  1. Jason Says:

    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

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Tag Cloud

  • Recent Comments on Visio Guy

  • RSS The Latest from the Visio Guy Forum

  •