Monday 19 October 2015

Visio Advanced Tips

Text Block Tool

Just as you can move and rotate a shape relative to the page or to a group, you can move a text block relative to a shape! The text block is the conceptual rectangle that holds a shape’s text. It can be moved and rotated independently of the shape. Sitting at the top of the Standard toolbar, just below the big black A is the the Text Block Tool. You have to click the little drop-down triangle to get at it, like this:

Viso Text Block Tool
If you have a copy of Visio with the ribbon, you will find the Text Block Tool in the Tools group on the Home tab. Note: some shapes have protection and guarding that prevents you from doing this, so practice on simple shapes that you yourself have drawn until you get familiar with the tool. Shapesheet junkies will want to know that changes you make with the Text Block tool are reflected in the Text Transform section of the Shapesheet.

F2 Enters Text-edit Mode

It’s easy to select most Visio shapes and simply start typing. But sometimes you want to edit text that is already there, and double-clicking doesn’t always get you into text-edit mode. For these cases, F2 is the shortcut that will get you into text-editing mode. Just select a shape and press F2, and your shape’s text will become highlighted–ready and waiting for you to edit it. Pressing ESC will get you out of text-edit mode.

Setting Double-click to Edit Text

When you draw a simple rectangle or circle, the default double-click behavior is to enter text-edit mode. But if you draw a group, then double-clicking will probably just select one of the group’s sub-shapes. If you have text-heavy drawings with lots of text-containing shapes, you might want to set all shapes so that double-clicking enters text edit mode.

This is really easy to set up if you have an older version of Visio. All you need to do is:
  1. Select some shapes 
  2. Right-click and choose Format, Behavior, Double-click tab 
  3. Check the option button: Edit shape’s text
If you have a copy of Visio with the ribbon then you will have to firstly turn on the Developer tab to locate the Behavior control. Click the File tab and click Options. Under the Customize Ribbon heading, click the Developer tab checkbox to enable your developer tab. Now all you have to do is:

  1. Select some shapes
  2. Click the Developer tab and the Shape Design group
  3. Click the Behavior control
  4. Click the Double-click tab
  5. Check the option button: Edit shape’s text

In the Shapesheet, an event cell will receive a new formula. It looks like this:

EventDblClick = OPENTEXTWIN()

So if you’re making automation tools that set this behavior automatically, just set the EventDblClick cell!

Process Lists With LOOKUP and INDEX

When you want to work with lists of values on a Visio ShapeSheet use the LOOKUP and INDEX functions to help you out. You often need to know where an item is in a list, or retrieve a specific item from a list. LOOKUP tells you where an item is in a list.

LOOKUP(“three”,”one;two;three;four”) returns 2, as the list positions are zero-based. If the first argument isn’t in the list, the function returns -1. Notice that you can use LOOKUP to do text comparisons too, if you are into code obfuscation.

INDEX returns you the nth item in a list. Again, where n is a zero-based value. So INDEX(1,”one;two;three;four”) returns “two”. By default, the semi-colon is the ShapeSheet’s list-separator of choice, but both functions have optional arguments that let you specify a custom list-separator.

We can demonstrate both functions in a text-translation example. We have two lists of numbers: one in English, one in German. Using LOOKUP and INDEX, we can return the German value from the corresponding English value.

User.numsEN = “zero;one;two;three;four;five;six;seven;eight;nine”
User.numsDE = “null;eins;zwei;drei;vier;fünf;sechs;sieben;acht;neun”
User.valEN = “five” …this could come from ShapeText, or a Shape Data field, for example.

And now we create the calculation formula:
User.valDE = INDEX(LOOKUP(User.valEn, User.numsEN), User.numsDE)

As long as the lists match up, this will work. We get a number that indicates where User.valEN is in the list of English numbers. This index value is then used to return the German equivalent. So: “five” gives us an index of  4, which then points to “fünf”

Resize Font With Shape

ShapeSheeters often ask how to get their text to resize with the shape. Normally, font-size is independent of shape size, but sometimes text should behave less like information and more like graphics. In short, “How do you get font size to change with shape size?”

The easiest way to do this is to create a relationship between the current height of the shape and the original height of the shape, and multiply that by the original font size. The formula can live in the Char.Size cell and might look something like this:

Char.Size = 12pt * Height / 0.75 in 

Here, 12pt is the original font size, and 0.75 in is the original height of the shape. The expression will increase or decrease with the current Height of the shape, and the font size will correspondingly grow or shrink. You might want your text to react with the Width of the shape, or some combination of Height and Width.

No comments:

Post a Comment