Box that resizes in function of the a seperate textfield.

Started by plinius, November 17, 2010, 06:11:07 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

plinius

I hope this is the right place to post my question, if not please let me know...

I'm trying to make a diagram in visio which gets another form in function of several parameters.
To get it started I tried an easy example where I put in X and Y as a text field, and draw on another place a box with height  X and width  Y.

But I didn't succeed (in fact I don't even know where to start).
If possible I want to avoid embedded Excel  and VBA (the sheet should be used by other persons without changes in the default security settings).

Where can I start with this? A "general sample" is OK (I found nothing on internet although I searched quite a bit)...
Thanks in advance.

Paul Herber

Here's an example:
Drop a shape on the page, then menu Shape -> Shape Data (or Custom Properties in older version of Visio), define a property called width and set the type to Number and the Format to Floating with units. Set the value to the initial width you require, say 4cm. Now with the shape still selected, open its shapesheet (menu Window -> Show Shapesheet) and edit the Width cell, remove the current value, type an '=' then click on the width cell in the custom properties section.
Now you have a shape where the width is controlled by the value in the custom properties.
Oh yes, you'll also need to add a guard(..) around the formula you entered above.
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

plinius

Thanks, this works indeed!
However this links a "shape data" to the form of the shape, but when I add a text field (using the Text tool from the toolbar) I cannot find the value of the text I just typed in the shapesheet.  So I cannot immediately link the text field with the box size...

I discovered in another post that I can make also "shape data" for the textfield, which I put on "shapetext(TheText)".
I guess I can put the Width en Height of the box equal to a "shape data" of another shape.
But here the problem is that the shape data for the text should be of the string type, and a Width is a float. So I'm still stuck..


(Sorry, but as you can see I'm still learning Visio)

wapperdude

#3
Try this formula instead:  =GUARD(SHAPETEXT(TheText)).

This assumes that your shape text that was entered is simply a number, e.g., 12.  But, this will only do a single value, not separate values for width and height.

You may want to check out this link regarding shapesheets:  http://msdn.microsoft.com/en-us/library/ms427031.aspx

HTH
Wapperdude
Visio 2019 Pro

plinius

Thanks, found it when you were typing your replie  ;D.

=INT(SHAPETEXT(Sheet.2!TheText))

Does indeed the trick.

Thanks for the link also.

wapperdude

#5
You can do a variation of Paul's suggestion, but text entry is not straight forward typing.

Create two custom properties, one for width (X) and one for height (Y).  As Paul indicated, you can enter the appropriate formula for width and height cells.  Note, if you keep the property as a string, I believe the shape assumes the sheet proporties for dimensions.

Now to have your values show in the shape, with the shape selected, go to Insert > Field, and select custom.  Assuming that the two properties were called prop.wid and prop.ht, then, in the custom formula, enter ="Width: "&Prop.Wid&CHAR(10)&"Height: "&Prop.Ht.  Note, you could eliminate the "Width: "& and the "Height: "& if all you want to show are the values.  char(10) is linefeed.  

But, to maintain everything, the values should not be typed in directly into the shape, but entered thru the custom properties menu.

Wapperdude

Visio 2019 Pro

plinius

Thanks Wapperdude and Paul.

Glad I found this forum, I learned a lot in a few hours !

Plinius

Jumpy

In case you don't already know. In the menu "View" (Visio 2007, don't know where to find in 2010) you find a option "Shape Data Window". This opens a "all the time visible" Window with the Shape Data, where you can directly see and manipulate the ShapeData. With that open, there is no need for Text Boxes I think.

If you still want to see the selected options on a print out, you can creare a user defined cell, that contains all the Info and display that in a (seperate) textbox, using Insert->Field and selecting the user defined cell. The cell could contain a formula like:

="Width: " & Prop.Wid & CHR(10) & "Height: " & Prop.Ht & CHR(10) & .....

plinius

Thanks, hadn't discovered this one indeed  :)

I have one more minor question:
When I create a box with a calculated length, it is always referenced around a certain middle point. So if I want the box to START at a certain PinX I always have to come up with pretty annoying formulas to do the trick. It's not that hard, but I imagine there should be a more elegant way (e.g. making a box which has it reference point on the left side instead of in the middle, or somewhere in the shapesheet setting a value between  guard(..),...)

I tried some of these, but I had no luck so far, so...

Paul Herber

Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

Jumpy

In the ShapeSheet you find LocPinX and LocPinY. If you imagine PinX and PinY as the point, where a needle pins your  shape to the paper, than LocPinX/Y defines the point on the shape, where the needle wents through.

Set both to 0 for the shapelength and -height to start in the bottom left corner.

wapperdude

For an illustration of what "Pin" vs "LocPin" does, see VisioGuy's blog entry, Pin and LocPin Illustration, found here:  http://www.visguy.com/archive-index/visio-art/.  You will need to scroll down quite aways.

Wapperdude
Visio 2019 Pro

plinius

Thanks all for your replies. The visio drawing with Pin and loPin all made it clear. I finally understand now.