Development

Tips & code for programming Visio & using the ShapeSheet

Maps & Geography

Maps & geography shapes & templates galore!

Network

Shapes & tools for Visio network diagrams.

News

Find out what’s new in the Visio world!

Shapes

Download useful & attractive Visio shapes. For free!

where can i buy windows 7 cheapest buy windows 7 upgrade from xp windows vista purchase price buy inventor 2010 pctools spyware doctor 5.5 buy windows 7 best price norton ghost 12 product key windows 7 price future shop windows xp price singapore windows 2008 web server download omnipage coupon buy windows 7 starter download adobe indesign cs3 for mac buy vista to windows 7 microsoft project 2003 download buy windows xp operating system windows 7 home premium cheap mathcad pricing photoshop buy mac discount autocad 2009 purchase microsoft money 2007 deluxe download photoshop mac autodesk maya 2009 price windows vista business download windows 7 price 64 bit purchase windows 7 ultimate full version buy windows 7 home premium key lightroom for apple purchase windows xp india adobe cs4 photoshop buy where to buy encarta 2009 purchase vista oem buy windows 7 tesco cheap adobe fireworks windows 7 price online best price corel draw 11 mac discount powerpoint buy microsoft office for mac canada buy microsoft project 2002 adobe production premium mac turbotax 2009 deluxe best price windows 7 ultimate 64 bit best price buy windows 7 amazon adobe flash pricing adobe dreamweaver sale purchase windows 7 ultimate buy quickbooks pro 2007 roxio copy & convert 3 buy download photoshop elements 6 steinberg nuendo price uniblue registrybooster 2009 download cheap photoshop programs adobe photoshop elements cheapest buy windows 7 future shop adobe presenter 7 download microsoft office 2003 sale buy quarkxpress 8 for mac purchase adobe cs3 design premium purchase after effects cs3 paperport professional 12 prices cakewalk download parallels desktop price buy microsoft windows 7 home premium cheap adobe after effects for mac how to purchase windows 7 online download microsoft streets and trips 2008 microsoft office 2003 cheapest buy windows 7 online singapore purchase autodesk 3ds max 2009 buy windows xp pro best price adobe flash cs3 buy uniblue registrybooster 2009 cheap windows 7 ultimate retail buy autodesk autocad buy microsoft office document imaging purchase microsoft office 2003 buy windows xp media centre edition discount microsoft windows 7 ultimate windows 7 price upgrade cheap adobe photoshop software burnaware professional price buy acronis true image 2010 windows 7 price change buy acrobat 7 where to buy adobe flash cs3 quicken 2010 price buy windows xp corporate buy office 2007 student product key windows 7 price hong kong buy windows 7 64 buy acrobat professional 9 symantec winfax pro 10.4 buy cheap windows 7 keys adobe photoshop cs4 buy buy microsoft visio 2007 turbotax deluxe 2009 download windows xp price in rupees buy lightroom software buy windows 7 buy windows 7 serial key steinberg nuendo 3 download download autodesk 3ds max 9 buy ms project online windows 7 price egypt windows 2008 enterprise download parallels mac download adobe lightroom sale cheap cubase 5 where to buy windows xp service pack 2 purchase windows vista download cheap windows 7 in singapore lowest price microsoft office purchase windows 7 license key where can i buy windows 7 starter edition buy i.r.i.s. readiris pro 11 cheap windows xp operating system buy office 2003 key where to buy windows xp cheap autocad mechanical 2009 download buy matlab software buy 3ds max 2010 student download dragon naturally speaking autocad inventor download get autocad 2010 buy adobe illustrator cs2 buy windows 7 mac windows xp price canada steinberg cubase sx3 download cheap windows 2003 enterprise download adobe illustrator cs3 can i buy windows xp online windows xp price in malaysia buy adobe cs4 suite best price adobe illustrator cs3 download font folio 11 acdsee pro license key cs3 production premium mac ms streets and trips 2008 download download adobe illustrator mac windows 7 price in india where can i buy cubase sx3 windows vista download iso roxio creator 2010 coupon code microsoft office price student windows 7 home premium 64 bit oem buy microsoft frontpage software buy windows xp 64 pro cheap windows 7 home premium full version buy burnaware professional cheap microsoft works 9 microsoft visio download adobe cs4 web premium oem download disk director cheap adobe creative suite cs4 microsoft money home and business download buy parallels desktop 5 for mac cheapest norton 360 3.0 lightroom price buy windows vista pro microsoft money buy online buy microsoft expression blend 3 buy windows 7 full version for students purchase lightroom 2 buy microsoft office ultimate pdf converter professional 6 promotional code buy adobe cs3 design premium buy indesign cs3 software buy windows vista ultimate upgrade acdsee photo editor download microsoft office 2003 professional cheap windows 7 for college students illustrator cs3 download download adobe indesign cs4 cyberlink powerdirector prices buy windows vista ultimate license buy access 2003 online windows 7 price guide mathcad price buy after effects cs4 mac cheap fl studio 8 xxl cheap photoshop elements 8 buy windows vista home premium oem buy wordperfect x3 buy windows 7 home premium 64 bit buy windows 7 brisbane buy windows 7 bangkok autodesk mudbox price purchase vista license cheap adobe premiere elements 8 download adobe creative suite 4 design premium best price microsoft excel 2003 buy microsoft project 2000 microsoft expression price discount photoshop elements 8 cheap maya software 3ds max sale buy windows 7 ebay windows 7 price 2010 deskshare videoeditmagic 4.3 price buy windows xp 2010 norton 360 price comparison buy windows xp used adobe contribute mac purchase windows 7 for mac buy windows vista home premium product key buy windows 2003 datacenter buy windows 7 professional cheap microsoft windows 7 ultimate buy sony vegas pro 8 purchase access 2007 final cut express 4 cost download microsoft visio 2007 buy onenote 2003 photoshop lightroom for mac symantec pcanywhere download windows 7 price pakistan buy premiere pro cs3 cheap windows 7 for students in australia web page maker 3 download buy windows xp home sp3 adobe photoshop best buy cheap windows 2008 enterprise buy windows 7 direct download download microsoft mappoint 2009 buy windows xp home download microsoft autoroute 2007 europe ashampoo burning studio download buy windows xp calgary archicad 13 download adobe cs4 design premium trial price photoshop elements 8 windows 7 home premium cheapest autodesk lustre pricing purchase archicad 13 acdsee pro 2 download windows 7 discount canada vmware workstation 7 download discount autodesk 3ds max 2009 buy autodesk inventor professional buy windows xp home full version buy windows 7 language pack buy microsoft office 07 buy microsoft excel 2007 download propellerhead reason 4 mappoint 2009 european buy access 2007 only buy frontpage 2003 purchase windows 7 ultimate online purchase microsoft windows vista buy dragon naturally speaking 10 oil price vista gadget pinnacle studio 14 best price cheap corel video studio pro x2 buy photoshop 7 for mac buy adobe cs3 design premium mac download ashampoo burning studio 9 cheap microsoft project 2007 dvd ripper platinum 5 buy adobe premiere pro cs4 download best price microsoft windows vista windows 7 discount for high school students purchase windows 7 professional (64 bit) compare price photoshop buy windows 7 philippines buy microsoft office powerpoint 2007 purchase windows xp sp3 buy photoshop elements 8 mcafee total protection 2009 download best buy autocad 2009 buy windows vista singapore purchase windows 7 now buy windows xp mumbai buy windows 7 ultimate 64 bit oem windows 7 price kenya ms works download adobe acrobat 9 oem buy windows 7 downloadable adobe cs4 web premium trial cheap windows 7 professional best price windows 7 home premium oem download adobe photoshop elements 6 navisworks manage price windows 7 price comparison buy guitar pro 5.2 download acronis true image 11 buy nero 8 ultra edition acdsee price download adobe robohelp 8 buy powerdirector 7 ultra imsi turbofloorplan home and landscape pro 12 buy buy microsoft expression studio 2 windows 7 discount for military buy windows 7 30 download pinnacle studio 12 ultimate adobe acrobat price comparison mappoint 2009 europe buy cheap avanquest mylogomaker professional 2 buy windows xp cheap microsoft office discount code buy windows 7 switzerland buy windows xp volume license buy norton 360 download cheap adobe photoshop cs3 download microsoft expression studio 3 buy office 2010 professional fl studio 8 xxl download buy microsoft office 2007 home and student cheap adobe cs4 design premium abbyy finereader 9.0 express edition where to buy streets and trips 2010 office 2007 price student buy roxio creator 2010 cheap adobe cs4 master collection mac buy windows xp ebay cheap indesign software buy corel photoimpact x3 download avanquest mylogomaker professional 2 cheap ashampoo burning studio 8 adobe captivate pricing autocad architecture oem buy microsoft office pro 2007 where can i buy powerpoint 2003 turbo tax cost buy windows 7 india online purchase windows 7 license online buy adobe flash cs4 buy windows vista ultimate product key buy cs4 mac buy adobe indesign cs4 best buy microsoft windows 7 ultimate cheap adobe dreamweaver cs4 mac cheap windows 7 canada roxio creator 2009 special edition microsoft office 2010 price in india windows 7 price canadian buy windows xp embedded download corel draw 12 adobe creative suite 4 production premium download buy adobe photoshop cs3 extended buy windows vista business 64 bit buy ms office 2003 pro best buy quicken 2010 buy microsoft office for mac cheap buy adobe after effects cs4 cheap norton 360 3.0 best price adobe cs4 master collection windows 7 price for teachers buy windows xp student purchase adobe acrobat 8 professional buy sql server guitar pro 5 mac download
Home » ShapeSheet

Evaluate Shape Text With EvalText

Submitted by Visio Guy on March 10, 2009 – 10:46 pm | | 4183 views 15 Comments

calculatorIt is pretty easy to type text onto a Visio shape. And linking text to shape data fields takes just a quick visit to Insert > Field.

But did you know that you can use Visio shape text as a data source? That you can evaluate it as a meaningful number or useful quantity?

Today, we’ll show you a few tricks that will allow you to use shape text as quantifiable  data that you can take action on.

No “Text” Cell

If you scour the ShapeSheet, you won’t find any “Text” cell that magically holds the text of the shape. Sure, you’ll find ShapeSheet sections for Text Fields, Character, Paragraph, Tabs and Text Block Format,  but you won’t find any Text cell in any of them.

While there are good reasons for this, I think this can initially trip-up would-be SmartShape designers.

The reason there is no text cell is because text can have different formatting characteristics. Bold, italic, underline, strike-through, bullets, font size, etc. Paragraphs can have different alignment. Some text might be typed by the user, other bits of text might be linked to inserted fields. In short, a shape’s text can be an unpredictable mish-mash. In light of all of this text-complexity, simply asking Microsoft for a Text cell might be a rather unclear feature request.

Workaround #1 to this problem is to insert a field that is linked to a Shape Data cell or a User-defined ShapeSheet cell. This allows you to control what is displayed in a shape’s text via data and logic stored in the shape. But it doesn’t solve the problem of utilizing text that the user types into a shape.

Make Sense of User-typed Text

We can’t directly modify the text a user types into a Visio shape using only the ShapeSheet. And if we have inserted fields that do smart things, the user is likely to destroy these fields by typing (unless we lock down the text and restrict any editing)

But we can respond to that text by using a special function: EVALTEXT!

With EVALTEXT, we can evaluate user-typed text as a number or a number-unit pair.

The syntax for EVALTEXT looks like this:

= EVALTEXT(TheText)
= EVALTEXT(Sheet.23!TheText)

TheText is a special token that tells Visio to either look at the text that is typed into the shape that contains the formula, or if we are using the “bang” notation, to look at another shape’s text. In this example, “Sheet.23!” is an identifier to some other shape on the page.

We are likely to enter this formula in a User-defined cell to do some sort of calculation, or to store the value for use with other cell’s calculations. You might end up with expressions that look like this in your ShapeSheet:

User.myTextValue = EVALTEXT(TheText)

or

User.myTextValue = EVALTEXT(Shape.24!TheText)

EVALTEXT will look at the entire text block and try to make sense of it. If the text is an expression that Visio understands as a valid mathematical or ShapeSheet expression, you will get a nice value that you can put to good use.

For example, say a user typed the following text into a shape:

0*1000 + 73

our function would look like–and evaluate to–this:

EVALTEXT(TheText) = 73

It is interesting to note that EVALTEXT cannot take a string as an argument. So EVALTEXT(“1 + 2″) will not give you anything useful as a result.

You might see that this capability will allow us to quickly build a “Scientific Calculator Shape”, or a “Visio Expression Tester Shape”. And that’s just what we’ll do to further illustrate the power of this function, and cover a few other SmartShape related techniques as well!

Let’s Build a Visio ShapeSheet Calculator Shape!

We’re now going to build a Visio SmartShape that works like a free-form calculator. Whatever text you type into the shape will be evaluated by our special ShapeSheet function.

Build the Calculator Parts

We’ll want to build a shape that has two rectangles, grouped together. The top rectangle will take our text, and the bottom rectangle will show the results:

evaltext-calculator

click to see larger image

Here, I’ve drawn the two rectangles and grouped them together. You can see how the top text is evaluated in the bottom rectangle. Also note that I’ve found the “Sheet IDs” for each shape: the top block, the bottom block and the group itself. These will come in handy for building proper ShapeSheet formulas.

To find out how to discover a shape’s ID, read the article SmartShape Tutorial: Fading Trees. You’ll find the ID-related stuff in the Sheet ID section.

Insert the Evaluation Formula

Now that you know the id of the top rectangle, sub-select the bottom rectangle and hit F2 to get into text-editing mode. Then, go to the menu: Insert > Field:

insert-evaltext-field

click to view larger image

You’ll see a dialog like this. Select Custom Field in the left list, then type a formula like: EVALTEXT(Sheet.2!TheText) into the Custom formula field, as shown. This tells the bottom rectangle to display the evaluation of the top rectangle’s text. In your case, Sheet.2 might have a different id, so make sure you get the right identification number!

Make the Top Rectangle Accept Text

Our calculator is just about ready to use, but there is still one detail to take care of.

If we select our grouped shape and start typing, the text goes to the wrong shape: it goes to the group!

We really want the text to go to the top rectangle, so we have to turn off the group’s text.

This is easy enough to do. Just go to Format > Behavior, then notice the Group behavior area. There, we can un-check Edit text of group. This easily turns off text-input at the group level. Now our text will go to the top-most sub-shape in the group, instead of the group itself:

group-doesnt-accept-text

click to view larger image

Now, I just mentioned the “top-most sub-shape”. What I really was talking about is the sub-shape that is foremost in the back-to-front sense. If the bottom rectangle is the top-most in the Z-order stack, we will destroy our inserted EVALTEXT formula. So we need to bring the top rectangle “to front”, ASAP!

Just sub-select the top rectangle and bring it to front via Shape > Order > Bring to Front, or simply Ctrl + F.

At this point, your calculator should work just fine. Select the group and type in an expression. The top rectangle should display what you’ve typed, and the bottom rectangle should evaluate it, as you type!

A Powerful Calculator!

Not only can you quickly input mathematical expressions, like 3 * 4 and get 12 back right away, but you can also enter complicated formulas that use functions that are understood by the ShapeSheet.

Here we’ve added a bit of trigonometry to the mix:

complex-formulas

And since EVALTEXT is really performing a Visio ShapeSheet evaluation, you can even refer to other shapes and concatenate text.

There are lots of ShapeSheet functions that you can use: Ln(), Sin(), Cos(), Atan2(), Min(), Max(), etc. You can specify units like deg, rad, in, cm, mm, m and so-on. Just play around and see what you can discover!

Our next example gets tricky with some string concatenation.

Below, Sheet.4 is our group, and we are referring to it’s width by using the syntax “Sheet.4!Width. We then pre-pend the text “Length = ” to the expression and our calculator handles it just fine! Also, Visio knows that we are talking about a length, not just a number: see how it includes the inches tick-marks just after 1.75?

concatenation-and-sheet-references

Note: Visio tries to automatically replace simple-quotes with “pretty quotes”–the ones that look like 66 99. These are not properly evaluated by EVALTEXT. So you’ll have to quickly type undo after you type each quote mark to get it to be the simpler version, or find the auto-replace options and turn off quote marks.

Visio does some interesting type-conversions. I’m not sure if I agree with this one:

percent

And you can mix and match decimals, plus, minus, and division using the forward-slash character:

decimals-and-division

Here, Visio (or Office?) tried to ruin things again by inserting a long-dash for a minus sign. I had to undo after typing the minus sign, because EVALTEXT didn’t take the long dash as a mathematical operator.

The calculator shape is a very old idea that actually worked much better in older versions of Visio that didn’t have the auto replace feature!

Final Touches

Before you rush off and create your own calculator, I’ll throw out two more tips that will help you to finely-tune and polish your calculator SmartShape.

Non-text Sub-shapes

If you’ve been watching carefully, you will have noticed the vertical “=” sign in the shape I’ve shown here. Clearly it is the top-most sub-shape in the group, which should interfere with the text input. Ie: the equals sign should be intercepting the text typed into the shape–which make things rather ugly.

The way to avoid this is to lock text editing on any “foreground” shapes that have nothing to do with text. You do this via the Format > Protection menu:

lock-text

Now you can easily add foreground elements to your shape to make it prettier without having to worry about text messing things up. You’ll see that I’ve added some black and white lines to add a bit of 3D effect to the shape. These are also “front-most”, but have locked text so they don’t affect text-input to the calculator.

Stop Sub-selection by Users

Once your calculator is built, users won’t have a need to sub-select anything. It makes the shape feel more solid and well-built if you can prevent accidental sub-selection of the group’s members. It also avoids potential confusion for users who aren’t so sure if they’ve sub-selected a shape.

You can make a group feel like a single entity by going again to the Format > Behavior dialog, and selecting Group only from the Selection drop-down list:

group-only-selection

Now your group will behave like a single, sealed shape and users won’t be confused by accidental sub-selections!

Related Posts

  1. Top Twelve Text Tips
  2. Text to the Bottom of the Shape
  3. Visio Microphone Shape
  4. Choose Colors with Shape Data Fields
  5. Consumer Reports Rating Shape

15 Comments »

  • Gary says:

    Thanks for the great article. I can certainly see that using EVALTEXT offers all sorts of timesaving and functionality opportunities.

  • Visio Guy says:

    You’re welcome, Gary. Thanks for stopping by and for leaving a comment!

  • satheesh says:

    hi,
    i need to display the page number in ‘xx’ format (that is 00, 01, 02 etc.) in Visio. i use VC++ IDE to update the cells in the shapesheet. i need to change the format of the page number based on a user selection (“xx” or “xxx” or “x” …). please let me knoe how to go about doing this.

    Thanks in advance,
    Satz

  • Visio Guy says:

    Hi Satheesh,

    Another Visio Guy article has an example of a shape that has variable formatting for one of its data fields. Have a look at it: Title Block #2: Let’s Make a Multi-field SmartShape!.

    The ShapeSheet has a FORMAT function that is similar to other applications. You’ll need to do something like:

    shp.Cells(“Prop.Date”).Formula = “FORMAT( dateval, \”00\” )”

    Assuming that your shape text is linked to a Shape Data (Custom Property) value. If you are programmatically inserting a field then your code will be different, but the formula will still be similar.

  • satheesh says:

    hi,
    Thanks for your response.

    I am displaying the Page number in a background shape. i did this using Insert-> Field-> Page Info category. this places a method PAGENUMBER() on the text field cell of the shapesheet. i feel that this PAGENUMBER() method just automatically adds a page number when a new page is included in the vst file (in sequence).

    1. I wanted to know where i can use the formula which u have mentioned in the above writing.
    2. I read the article u had specified which shows “A;B;C” for the date. how can i modify it for my case.

    Please not that I am an amateur in Visio. I am still learning the basics of it. :-)

    Thanks a million,
    Satheesh

  • satheesh says:

    hi Visio Guy,

    Thanks for your reply. i was able to control the length of the page number using the formula which u had posted earlier :)
    please ignore the previous post.

    thanks a ton
    satz

  • Visio Guy says:

    Hi Satz,

    Glad to hear you figured it out!

    - Chris

  • satheesh says:

    Hi,
    i have a shape which is a group of several shapes. i need to add few more shapes to the group. when i ungroup, add the new shapes and group it again, all the settings of the previously grouped shape is lost. is there any way where i can retain the settings? or is that the normal working of Visio which cant be changed? :)

  • Visio Guy says:

    Hi Sateesh,

    When you ungroup, you destroy the group. If there were any references or smart relationships with the group, then of course they will be gone (where would they go?)

    But you can open a group instead of ungrouping. Select a grouped shape, then go to Edit > Open [shapename]. You’ll get a new window that is a view inside the group.

    That should save you some time!

    - Chris

  • Diane says:

    From what I have learned so far about Visio, there is no way of adding a fixed amount of text into a fixed shape. Is this true? If not, can you please tell me how to do this (step by step)? It would be soooooooo helpful. Thank you!

    Diane

  • Visio Guy says:

    Hi Diane,

    I’m afraid I don’t know what you mean by fixed amount of text. I could select a shape and type “Fixed amount”, and that would be, erm, a fixed amount of text wouldn’t it? So I’m obviously not understanding your question.

    - Chris

  • Pretz says:

    Hi there,

    I was wondering if you could please help me with the following:

    I have currently 100 boxes with texts inside them. I want to search for the text inside those boxes that i shall manually select and want visio to automatically position them.

    For eg:

    IF Selected_Shape contains “Cat”

    then Move selected shape to (0,-4)

    ELSEIF Selected_Shape contains “DOG”

    then Move Selected_Shape to (3,-5.7)
    and so on

    I am a total amateur to Visio VBA. Please can you help.

    Thanks

  • satheesh says:

    Hi,

    I have a problem.
    I made a few changes in the textfield section of a text box (under a group) in a few Visio templates (.vst files). I have hundreds of such templates and all those require the same changes. Making changes on all these templates manually is time consuming. Is there any way where i can automate this? May be a macro or something else??
    please help me on this.

    Thanks,
    Satz

  • Visio Guy says:

    Hi Sateesh,

    Yes, you can do this with macros and VBA. With Visio automation, you can open and save Visio documents. You can scan through all of the shapes in a Page.Shapes collection and make changes.

    You can get an idea of how Visio automation works from these articles:

    Combo Box Table of Contents

    Connect All Shapes to Each Other

    Create Visio Flowcharts Programmatically

  • Vijay says:

    I have few sheets in a Visio file. I have a shape (in one of the sheets) and in the shape data, I want create a hyperlink to go to one of the other sheets. Is this doable?

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

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>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.