If you are designing your own shapes, you’ll spend a lot of time manipulating text.
And the more you learn about Visio’s capabilities, the more you’ll want to control shape text. Oh yes, you’ll want to rotate it, reposition it, evaluate it, make it reflect data, make it resize with the shape, and much, much more.
Today we have a treatise on twelve text tips for both end-users and ShapeSheet fans.
The Top Twelve Tips
This list could have easily been twenty-two tips long, but we had to trim. In today’s top-twelve Visio text tips, we’ll address these issues in moderate detail:
- Using the text block tool to reposition text on a shape
- Quick text-editing using F2 to get into text-edit mode
- Setting double-click to edit the text of a shape
- Linking shape data fields to shape text
- Keep text on the level
- Find out: how big is your text block?
- Evaluate shape text as input data
- Comparing strings in the ShapeSheet
- Gravity text
- Process and manipulate lists of values with lookup and indexing functions
- Resize font with shape
- Reposition text with a control handle
1. The 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:
Give it a try. 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.
2. F2 Enters Text-edit Mode
Sure 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 a 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.
Escape (Esc) will get you out of text-edit mode.
3. 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 sub-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. All you need to do is:
- Select a bunch of shapes
- Go to: Format > Behavior > Double-click tab
- Check the radio button: Edit shape’s text
- Click OK
Inside of 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!
4. Link Text to Shape Data Fields (Custom Properties)
If you want to display data stored behind your shape in the shape’s text, it’s as easy as inserting a field. Here’s the short list of what to do:
- Select a shape that has shape data fields, like the ThinkPad shape shown below
- Hit F2 to get into text-edit mode (like in tip #2!)
- Go to: Insert > Field
- Select Shape Data or User-defined cells (or other info about the shape or document) in the Category column
- Choose the info you want and specify formatting
You can insert more than one field by moving the text-edit cursor around and going back to the Field dialog. You can also enter custom ShapeSheet-valid expressions if you don’t find what you need in the pre-defined set of fields.
5. Level With Your Text!
Sometimes you want your text to stay level — that’s right-side-up and readable without neck pain — no matter how the user rotates those darn shapes. For instance, if you rotate a shape that has “normal” or default text, you’ll get something that looks like this:
But if you set up “Anti Rotate” text, you’ll get this pleasing result:
As you might guess from the hints in the images above, you can cause text to anti-rotate using ShapeSheet formulas.
We’ve already mentioned that the Text Block tool causes changes to cells in the Text Transform section. Well one of those cells specifies the angle at which the text is rotated, relative to the shape: TxtAngle.
The easiest make text anti-rotate is to get it to compensate for any rotation of the shape by anti-rotating the text. The expression is pretty simple: just make the text rotate in the opposite direction as the shape:
TxtAngle = -Angle
Your shape rotates, your text anti-rotates. Pretty simple.
But, if your users get tricky, they might flip the shape, which will break this formula. A more robust version looks like this:
TxtAngle = IF(BITXOR(FlipX, FlipY), Angle, -Angle)
One note about the Text Tranform section. If your shape’s text block is default–ie: it hasn’t been manipulated, then you won’t see the section in the ShapeSheet. Oddly, you have to add it (as opposed to show it) but this is simply a matter of going to Insert > Section, and checking the Text Tranform box.
6. How Big is Your Block?
It’s very helpful to know just how big your text block is. Two lovely ShapeSheet functions will help you get there: TEXTWIDTH and TEXTHEIGHT.
They don’t have to live in the TextTransform section, but they’re often found there:
TxtWidth = TEXTWIDTH(TheText)
TxtHeight = TEXTHEIGHT(TheText, TxtWidth)
Normally, TxtWidth and TxtHeight are as big as the shape itself, but if you want to position text tightly against an edge of the shape, and have it react to any text the user might input, then you’ll want to learn these formulas.
The formulas shown above will cause your text to tightly enclose any text you type on the shape, plus the top, bottom, left and right margins. With these formulas, you can position text exactly against an outside edge of the shape.
So, for instance, to place text on the right side of a shape, you could set the TxtPinX cell as follows:
TxtPinX = Width + TxtWidth/2
As the text grows, TxtWidth will grow, and the text will move off of the edge of the shape (the text’s pin is in the middle of the text)
Similarly, you can position text off of the bottom of the shape like this:
TxtPinY = -TxtHeight/2
Note that the last two examples assumed that the text’s pin was at the center of the text block. This is handy if you are also going to implement anti-rotating text.
But if your shapes will always be right-side up, you can do some simplification by playing with the TxtPin and the TxtLocPin. The TxtPin is the position at which the text block is located, relative to the shape. The TxtLocPin is where that pin is located inside of the text block itself.
I know, it’s a bit cumbersome to describe with…erm…text, so try it out for yourself!
7. The Value of Words
The text on your shapes can be more than just a bunch of pretty characters. It can specify meaningful quantities.
As long as the text adheres to valid ShapeSheet syntax, then it can be validated. Now I know that “valid ShapeSheet syntax” sounds ominous and daunting, but it doesn’t look much different then, say, Microsoft Excel formula syntax. So this won’t be anything new to lots of you.
To convert shape text to numbers, you use the EVALTEXT function. It will try its very best to make numerical sense out of the text you type. For instance, this formula:
Width = EVALTEXT(TheText)
Will cause your shape to grow in width to the size of whatever your shape’s text evaluates to. The obvious danger is that your text will evaluate to zero (ie, you type: “Schmoosabbfgrfflk”) and your shape will disappear! But it is still a pretty cool feature, plus you can use IF statements to trap zero evaluations.
You can easily try this out by doing this:
- Draw a rectangle on a page
- Type “1.5” or “25mm” or something in the shape’s text (so our shape doesn’t disappear in step 4!)
- Open up the ShapeSheet via: Window > Show ShapeSheet
- In the Width cell, enter the formulas shown above
- Close the ShapeSheet window, and start typing on your shape
Now have some fun. Try typing: Sin(45deg) + PI()^2 – 3417-4/9, or something equally obscure.
As long as the text is valid ShapeSheet syntax, then you’ll get an evaluation. If you don’t type in any units, then the result will be in inches, but you should be able to type mm, m, cm, in, yd, etc. as well as formulaeic expressions.
You can build a scientific calculator with just two shapes: one shape takes your input, the other displays the output. And the output evaluates as you type! This is described in detail in this article: Evaluate Shape Text With EvalText
8. Comparing Strings
A lot of people jump head-first into the ShapeSheet, only to surface minutes later in the newsgroups. They set up a shape with Shape Data fields like “Color” and allow values such as “Red”, “Blue” and “Pink”.
Then they try to make decisions on these named values and format the shape accordingly. They try stuff like:
FillForegnd = IF(Prop.Color = “Red”, RGB(255,0,0), …)
And it doesn’t work!
The problem is that Visio evaluates text as best as it can. So “Red” = “Red”, but “Red” = “Blue” as well, because they both evaluate to ZERO!
If you want to compare strings, you need to use the STRSAME( ) function, which was added in Visio 5.0 (I think). Here’s an example:
FillForegnd = IF( STRSAME( SHAPETEXT( TheText ), “Red”, TRUE), 2, 0 )
This will turn your shape red if you type “Red” or “red” into the shape. Pretty cool, huh? Note, the TRUE argument is optional, and allows for case-sensitivity. TRUE ignores case, and FALSE respects it.
9. The Gravity of the Situation
If you’ve got lots of shapes on a page, and they are rotated at arbitrary angles, then the drawing can get visually confusing, very quickly. Sure, you could try the anti-rotate technique from tip #5, but sometimes text should orient along the shape.
Have a look at this mess:
See how the text “points” in all directions? It is very jumbled to look at.
Now take a gander at this:
The shapes are arranged exactly as in the first example, but the text is cleaner. It tends towards the bottom or the right-side of the page. The text appears more consistent, is more readable, but still orients along the axis of the containing shape.
This effect is achieved using the GRAVITY ShapeSheet function, which essentially rotates the text 180 degrees, under certain conditions.
The shapes in the second example use the GRAVITY function in the TxtAngle cell as follows:
TxtAngle = GRAVITY(Angle, -60 deg, 120 deg)
What happens is that TxtAngle is 0 deg between -60 and 120 deg, but flips 180 degrees for angles not in the range. Your text stays in-line with your shape, but is readable from the bottom or right-side of the page. That’s a lot less turning and flipping of the page, and less pain in your neck as well!
An illustration that was recently posted in Happy Pi Day…Sort Of, shows how GRAVITY effects text as a shape is rotated:
10. Process Lists With LOOKUP and INDEX
If you want to work with lists of values then Visio’s ShapeSheet provides the LOOKUP and INDEX functions to help you out.
Often times you 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. So 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 tells you the “Nth” item in a list. 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 highlight both functions in a text-translation example. We’ve got two lists of numbers: one in English, one in German. Using LOOKUP and INDEX, we can get the German value, given the English
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
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 is then used to grab the German equivalent. So: “five” gives us an index = 4, which then points to “fünf”
11. 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.
So the technically re-worded question is: “How do you get font size to change with shape size?”
The easiest way to do this is to build a ration 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.
There are lots of other factors to consider too, so luckily you can read the whole story here: Text Resizing with ShapeSheet Formulas
And if you have text that won’t be edited, you can use this technique: Resize Text With Metafiles!
12. Reposition Text With Control Handles
Lots of Visio shapes come with a feature that lets you easily reposition text using a little, yellow control handle. You can see it in action on this ThinkPad shape. See the yellow diamond peeking out from behind the cursor cross-hairs?
The problem that beginning shape developers have is that they try to hook a control handle to the text. But the paradigm is actually the reverse of this: you hook the text (location) to the (position of the) control handle.
Since this topic warrants a full article (and several utilities, probably), I”ll briefly describe the process of getting text to be repositionable via a control handle.
First, you add a control handle by inserting a row in the ShapeSheet. Then you set the TxtPinX and TxtPinY cells to refer to the position of the control handle. Now, when you move the little yellow diamond, your text will follow along!
In detail, it goes something like this:
- Create or select a shape (duh!)
- Open the ShapeSheet via Window > Show ShapeSheet
- Go to: Insert > Section and check Controls and Text Transform (if it isn’t grayed out)
You should now see both the Controls section and the Text Transform section in the ShapeSheet. - In the Text Transform section, set the TxtPin cells as follows:
TxtPinX = Controls.Row_1.X
TxtPinY = Controls.Row_1.Y - In the drawing window, reposition the control handle to a suitable default position. The text should follow along!
- Apply other text-handling techniques to the text block, as discussed in the other 11 items in this article!
But Wait, There’s More!
Well, that’s all we have time for this century today. But you’ll be glad to know that Visio Guy is choc-full of text-related articles. If you’ve had fun with our Top Twelve Text Tips, then I urge you to read these:
HH says
Excellent guide, some of them should be actual features of Visio though
Visio Guy says
Er, good point HH! 🙂
HH says
Well by features, I mean easily locatable features not requiring fiddling with the shape sheet. Very good article as well – helped me on a workflow diagram I drew this morning at work.
Sandeep says
Hi Visio guy,
Thank you for your informative articles. They are very helpful!!
I’m a designer and don’t understand much of coding. I’m in the process of making visio based stencils and currently working button stencil. What I wanted to know was how do I make sure the text that goes on the button is user defined? Also exploring ways to make sure the button’s graphic(length) is extended as per the user defined text.
Is there some sort of formula that I need to use here?
Appreciate your help.
– Sandeep
LoSt says
I’ve applied a theme to my org chart. However, everytime I change the text in one of the shapes, the color and text formatting reverts to the default reguardless of the theme settings. I’ve tried setting protection – format, but that doesn’t keep it from changing! How do I avoid having to re-color, re-size, re-bold, re-underline my text evertime I edit the text??!!
gagr says
Hello Mr. Guy!
I have a question that maybe you can help me with:
I have some shapes with a couple of Custom Properties (say PropA and PropB) and i am displaying PropA (using Insert/Field/Custom Properties).
Is there any way i can switch to PropB based on some page-level variable? For example, i change the value of the variable from “A” to “B” and all the shapes in the page display the text on PropB instead of PropA.
I can’t find any way to access the displayed text on the shapes…
– Gonçalo
Visio Guy says
Boa dia, Gonçalo!
You need some indirection to get this to happen.
On the page, how about something like this:
Prop.A = “Item A”
Prop.B = “Item B”
Prop.Display = …item a or item b…
On your shape:
Insert > Field > Custom Formula = ThePage!Prop.Display.
Now when you set Prop.Display on the page, your shapes will update.
gagr says
Working like a charm now, thanks a lot for the idea!
G.
deanimal says
Hi there, with regards to section 5 and the txtangle… is there a way to apply this to multiple shapes at once? I need to use this formula on about 300 items and it’s very slow adding it one at a time! I have tried group select and layer select but it only appies the formula to the first item you select. Any ideas??? >:(
Visio Guy says
Hi deanimal,
You’ll need a bit of code to make that happen. You can use the built-in VBA
[code lang=”vb”]
Sub SetManyFormulas
‘// Select a bunch of shapes, then run this procedure.
Dim shp As Visio.Shape
For Each shp In Visio.ActiveWindow.Selection
shp.Cells("TxtAngle").FormulaForceU = "-Angle"
Next shp
End Sub
[/code]
deanimal says
Hi Visio Guy,
Thanks for your help, I must confess to being a novice at VBA and macros! however I tried running your code (it adds it to the bottom of an existing macro?) but I get the error: unexpected end of file. what have I done wrong?
deanimal says
PS: also I want to use your formula: = IF(BITXOR(FlipX, FlipY), Angle, -Angle) is this possible? thank you
Visio Guy says
When you copy the code from this site, it looks like the apostrophes and quote marks are the fancy, curved style. When you paste the code into the VBA editor, make sure the quotes and apostrophes are the normal, simple, straight ones.
I’ve added code formatting above, so it might work better for you.
Yes, just paste the code at the bottom of the ThisDocument code page or any other module in the VBA editor. Put your cursor inside of the Sub, then hit F5 to run.
Make sure you’ve got shapes selected in the Visio drawing window.
deanimal says
Success!! Yay thank you very much, you’re a legend 🙂
MarkAl says
We use Visio for room layouts, and with different sized rooms, the drawing page needs to be at different scales. How can we get the text block to stay the same size (so that the text fills it the same way) regardless of the drawing scale?
Phil says
Hi Mr Visio guy. My issue is probably very simple to fix but I am perplexed.
In the Dimensioning – engineering (Metric) folder and selecting the “angle centre”. I can not flip over the shape despite performing the un-protect function to allow the numbers (in degrees) to increase from left to right, like the time on a clock. 0 degrees at the top and increasing in value in a clockwise direction. Why on earth Visio performs the motion in a counterclockwise direction is a mystery to me.
Visio Guy says
Hi Phil,
The shape was (theoretically) developed to label in the counterclockwise direction, as you would in Cartesian coordinates. Remember algebra, geometry and calculus?
But an angle doesn’t really have a direction. You don’t need to flip anything, nor unlock any protection (which was set by the shape designer on purpose!) You just have to switch the sides where you attach the dimension line handles.
Continuing with the clock metaphor…say you want to label from 3:00 to 4:00–a 30-deg sweep. Right now you are putting the base handles from the center to 3:00, then dragging the control handle to 4:00. This gives you the large outer angle (330 deg) instead of the inner angle.
Instead, place the base handles from the center to 4:00, then drag the control handle to the 3:00 position. You’ll have your 30 deg angle then!
Visio 2010 says
Hi Visio Guy,
Is there a function in visio 2010 that allows you to format the size of the text box or shape? Similar to the one in excel where you can format the size and height of the cell? I am working on formatting an org chart at work with tonnes of text boxes was hoping there was an easier option than manually formatting there size so they are all even.
Don says
Hi, very interesting articles.
I have a multi-page drawing and each page has various shapes… some of which have a number field ‘AMOUNT’.
I have a rectangle on each page and would like to display the total of all the AMOUNT fields on that page. From your article above, I see that it is possible to enter a custom formula field in the rectangle.
How would I write such a formula? And, would it automatically update if the value in any of those shapes were changed?
Ivo Milanov says
Gravity text is a partial solution that won’t work in rotated or flipped groups. A general Visio limiation of the ShapeSheet is that you do not have access to composed properties of the shapes such as its actual page transform.
Visio Guy says
You’re right, Ivo, the angle formulas won’t work for shapes buried within groups. One way to get around this is to use the ANGLETOLOC or ANGLETOPAR functions.
Using this, the angle of a shape can be compared to the page, no matter how deep it is within a group.
I believe the iPad shape in http://www.visguy.com/2010/12/19/apple-ipad-visio-shape/ uses this technique.
bertwest says
Hey Visguy,
HA! I finally found what I searched for! Thank you for the tips 11 and 12.
However… For some shapes I cannot see the little yellow diamond that should be shown. This handle is there, because I can move around the text just like it should work. But I have to “know” where the handle is because I can’t see it.
The only difference is that these shapes contain a picture.
Any ideas?
Thanks!
Bert
bertwest says
… Hey again,
I found the answer:
http://www.tech-archive.net/Archive/Visio/microsoft.public.visio.general/2005-06/msg00289.html
Just group the picture (only the picture 🙂 before you apply the text handle options and the yellow diamond is there.
Regards!
Bert
Visio Guy says
Hi Bert,
I remember this being a very odd problem – controls on shapes that were imported bitmaps did not show up. They were there, but you couldn’t see them. I suspect this was true for any “foreign object” (bitmaps, metafiles, jpgs, gifs, pngs, etc.)
I just ran a quick check in Visio 2010, and it appears they’ve fixed it. I paste metafiles and bitmaps into a drawing, then added control handles to each. They little yellow diamonds are happily visible!
Supert8ch says
I am not sure of where my problem is. I made a stencil group, it has about 20 shapes in it and took one of them to edit the text for rotating. But it does not change when I drag a new shape on the drawing and rotate it. The label is from an excel spread sheet and I drag the cell to the shape. I have the data graph set to view only 1 column of the overall data in the excel row.
Visio Guy says
Supert8ch,
Are you trying to get text inside an embedded Excel object to “anti-rotate” with the shape? I don’t understand your question(s).
Erik Dillenkofer says
We use “Smart” symbols on our engineering drawings, the symbols have text associated with them and the text strings are created based on user selections in a dialog window that contains drop down selection fields … example – if we are replacing a power pole, the user selects “REPLACE”, the pole height, the pole class, and a few other optional criteria (if necessary for that specific pole location), and the text associated with the pole symbol is generated. Everything worked fine from VISIO 5 up through VISIO 2003, but in VISIO 2007 and above PORTIONS of the generated text are not visible to the users on the screen or on the printed pages. If we view a drawing in VISIO 2003, the text is there, but view the same drawing in VISIO 2007 or higher and some of the text is not there! (In the example above, the pole height and class appears, but the “REMOVE” text does not appear). Can anyone provide any input on why this would occur or any solutions?
Visio Guy says
Hi Erik,
In Visio 2007/2010 can you open an old drawing, then select a text box and edit/unedit it (ie: add a space, then remove the space) and see if the text somehow updates?
I can’t remember specifics, but something regarding text changed between versions a while back, with the result that lots of ‘old’ text wrapped oddly when opened in newer versions.
Maybe try reducing the text block margins and see if that changes anything.
This is a first step at diagnosis, anyway.
baja says
Hi,
I am using Visio 2007 to make an org chart. The problem that I’m having is that once I go in to edit existing text in a box all of the formatting disappears when I click out of it. How do I keep the formatting? I have to start all over again in the boxes if I make a change to the text which makes things difficult.
baja says
Can anyone help me out with my question above?
Vicky says
Hi there.
I have created a 5 lane horizontal Visio with 3 vertical separator. I have filled each lane with a different colour. At the point I save my chart the separator lines are visible but when I re-open they have disappeared. Can you help? Thanks.
Michael Grosse says
Help…help…help….!!!
Hi Visioguy,
I imported drawings from Visio 2002 into Visio 2013. Now I opened them and the view is portrait. I cannot change to landscape because the program then automatically re sizes my drawing and the trick with gripping a corner of the drawing also does not work.
Any ideas…?
Thanks!
Michael
Visio Guy says
Hi Michael,
There’s no “Format Paint Sizes” function, but you can do this:
1. Select several org-boxes. Shift + Click will work nicely, or drag-select a rectangle around the boxes you’re interested in.
2. Click on the status bar in the lower-left of the Visio window, where it says Width or Height. This brings up the Size & Position window, where you can enter width and height measurements that will apply to all selected shapes.
Visio Guy says
@Vicky,
I haven’t seen that behavior before. Hopefully somebody else has and can offer some tips.
Troy0mjg says
Hello Visio Guy,
It seems like this should be a simple task but I have not been able to get it to work. Essentially, I want to create user-defined Document-Info, i.e. user-defined text fields that can be inserted into multiple pages within a Visio document. I tried adding a user-defined section to the ShapeSheet but when I select Insert, Field, User-defined Cells, nothing displays in the Field: and Format: boxes. I would appreciate it if you could point me to something that discusses how to do this.
Thanks,
Mike
Visio Guy says
Hi Mike,
You can add a user-cell to the Document’s ShapeSheet. Right-click on any page, then hold the Shift key and click Show ShapeSheet. This gets you to the document ShapeSheet.
Add a user cell there, say, User.Info. You can now reference it from other shape’s ShapeSheets or via Custom Formula in the insert field dialog. Use this syntax:
TheDoc!User.Info
Troy0mjg says
Hi Visio Guy,
Thanks for the speedy reply. I should’ve mentioned that I’m using Visio 2003. I get as far as opening the document ShapeSheet. How do I add a user cell? When I right click, my options are: Values, Formulas, View Section, Insert Section. I can add a User-defined Cells Section and enter a Value and Prompt but I when I try Insert, Field, User-defined Cells, there is nothing in the Field: and Format: boxes. What I’m trying to do is simulate the Document Info or Page Info functions to include my own tokens (labels) and associated values, e.g. Field: Site_Name (value “Data Center”) Format: Normal | Uppercase | Lowercase. Any chance you could provide a sample Visio of this?
Thanks again,
Mike
Visio Guy says
Hi Mike,
You have to choose Custom Formula at the bottom of the Insert > Field, Category list.
Then you can enter the formula in the Custom Formula box.
Sundog says
I need to hyperlink from a text box that has no fill or lines, but is on top of a graduated header. Ctrl+K lets me insert my hyperlink, but afterward I can’t find it to click it.
Do I need to actually put the text in a shape first? Difficult, since my text is on a color-graduated header that I probably could not match in an isolated shape.
Visio Guy says
Hi Sundog,
I think what I’ve done in the past is give the box a fill, then set the fill transparency to 100%. Essentially a clear shape, but the mouse still picks it up when you move over it.
Sundog says
Thanks! Will try.
Filippo says
Hi Visio Guy,
I use Visio 2007 in Italy, so all measurements are expressed in mm and not in inches. I wrote something like that, in order not to make my shape disappear when initially is contains no text:
Width=EVALTEXT(TheText)+10mm
As I type number characters, the shape’s width updates consequently, evaluating TheText in INCHES. But, if I type “10mm”, the shape correctly sets itself to a width of 20mm.
Now, I would like Visio to evaluate the text directly in mm so that the user could omit the “mm” at the end. I tried the following:
Width=EVALTEXT(TheText&”mm”)+10mm
but my shape remains 10mm long whatever text I would type, since the EVALTEXT returns always 0. In order to have a watch (is there a more “debug style” method to do that?) I create a new row under User-defined Cells and put TheText as the Prompt: I obtain always 0. Thinking that TheText would be evaluated only in the istant the event fired up, I tried to type some other text in the shape, but nothing… What’s wrong?
Thank you very much,
Filippo
Visio Guy says
Buon Giorno, Filippo!
The trick is to put the “casting” units on the left side of the expression. For example:
Width = 10mm + EVALTEXT(TheText)
See this article: Casting Units in Visio’s ShapeSheet
Filippo says
Guten Abend Visio Guy! 🙂
Thank you very much for the casting tip! But it seems not to solve my issue, since if I write “1” as the shape text, I get
Width = 10mm + EVALTEXT(1) = 35,4mm
that’s right but it’s not what I want (11mm).
What about TheText evaluating to 0 when I use it in other cells of the ShapeSheet?
Why EVALTEXT(TheText) works fine if I write “1mm” in the shape and doesn’t work at all if I code EVALTEXT(TheText&”mm”) having only “1” in the shape text?
Visio Guy says
Ok, so if no units are specified, then Visio defaults to “Internal Units”, which are inches, God Bless America!
If you know that the text won’t have units, then you could convert like this:
Width = 0mm + EVALTEXT(TheText)/25,4
EVALTEXT does not evaluate strings, so you can’t do this:
EVALTEXT("7 + 4 - 28")
However, the ShapeSheet will attempt to evaluate strings under certain circumstances.
For example, if you type:
User.Test = "7 + 4 - 28"
the result will be “7 + 4 – 28”. Ok, fine, a string.
But if you type
User.Text = 0 + "7 + 4 - 28"
the result will be -17! No need for EVALTEXT, you just need to put 0 + at the beginning to tell Visio that “this isn’t just a string”. Mixing in mathematical operators tells Visio to try and evaluate the expression inside the quotes.
Filippo says
Ok, I made some trials. What I have understood is that EVALTEXT() evaluates a shapesheet cell “hoping that it contains text” but cannot be used passing a string directly at it. The help infact says that the syntax is
EVALTEXT(shapename!Text)
and not simply EVALTEXT(string)
Quite a bit misleading…
There should be some concepts about events/cells that I still am not aware of, since I expect that writing =TheText in the User-defined Cells|Prompt cells would show…the text! (I also tried to write =LOWER(TheText) hoping to “cast” a string)
Visio Guy says
Yes, TheText is an odd ShapeSheet entity that represent the text of the a shape in a weird, abstract way. EVALTEXT takes only TheText or Sheet.N!TheText as an argument.
If you want to get a string in the ShapeSheet that represents a shape’s text, use this formula: User.MyText = SHAPETEXT(TheText).
Now you can LEFT, MID, RIGHT, SUBSTRING, etc. User.MyText.
Filippo says
GREAT!
Knowing that, I solved this way:
1) I created a new row (User.Row_3) in the User-defined Cells section, with
Prompt = SHAPETEXT(TheText)&”mm”
2) I modified in the Shape Transform section:
Width = DEPENDSON(User.Row_3.Prompt) + GETVAL(User.Row_3.Prompt)
I added the DEPENDSON() function because without that the width did not update itself after typing new text.
PS: I feel storing strings in the Prompt cell being all but a good programming practice, so where should I store strings? As Shape Data flagged as Invisible? Do the Scratch section only accept numbers?
Btw, thank you again!
Pete says
Dear Visio guy:
I am using data graphics with Visio 2010. All the shapes are the same…rectangular but
1) I want different data in each rectangle and
2) when I group the rectangles it keeps the other data graphics from being updated and basically starts a new data graphic to the side.
Is there a way to update (drag a row) in one step…basically drop the row to the box that contains 5 rectangles with different data?
Your help would be greatly appreciated.
Regards,
Pete