Visio Guy

Visio Discussions => General Visio => Topic started by: Grinsekatze on August 13, 2017, 05:10:28 PM

Title: ShapeSheet influenced by checkbox
Post by: Grinsekatze on August 13, 2017, 05:10:28 PM
Hey,

I am new to visio and I have 2 questions.

Can I connect control elements like a checkbox with a shape?
I want that the LineWeight changes if I select the checkbox. In the end, it should look like LineWeight=if(CheckBox1=True,12pt,40pt).

My second question is like the first one. I have a textbox and some dynamic connector. The connector should be invisible if the value in the textbox is higher as the properties of the connector. I tried
Geometry1.NoLine=if(textbox1>prop._VisDm_TestValue,TRUE,FALSE) but it is not working.

I hope you got my point and can help me.

Best regards
Title: Re: ShapeSheet influenced by checkbox
Post by: Yacine on August 13, 2017, 06:45:27 PM
Yes you can do it, but I rather recommend to stay with Visio's own UI.

For the check box, add a custom property to the page. eg Prop.LineWeight. Set its data type to fixed list. Write "12pt;40pt" in its format cell. Now in the shapesheet of the shape, go to the lineweight cell and write : "thepage!prop.lineweight".

Same process for the 2nd question.
Title: Re: ShapeSheet influenced by checkbox
Post by: wapperdude on August 14, 2017, 03:48:20 AM
Quoteif(textbox1>prop._VisDm_TestValue,TRUE,FALSE)
I don't think this does anything.

textbox1 doesn't refer to any variable that has a numeric value, or any type of value for that matter.

Wapperdude
Title: Re: ShapeSheet influenced by checkbox
Post by: Yacine on August 14, 2017, 07:00:24 AM
I couldn't find neither a direct way.

But using VBA, you can alter the value of a custom field of the page.
Private Sub TextBox1_Change()
ActivePage.PageSheet.Cells("prop.Row_1").FormulaU = Chr(34) & TextBox1.Text & Chr(34)
End Sub
Title: Re: ShapeSheet influenced by checkbox
Post by: Hey Ken on August 14, 2017, 12:57:11 PM
Grinsekatze:

   Got just what you need.  Attached is a Visio drawing with a checkbox shape.  Right click to check/uncheck/cross it, or enable/disable it.  The current state is kept in User.Status, which you can reference for your LineWeight IF.

   No idea why your NoLine does not work.  Let me suggest you put your complex IF in a User cell, then reference that in the NoLine.

   Good luck!

   - Ken


Title: Re: ShapeSheet influenced by checkbox
Post by: wapperdude on August 14, 2017, 10:44:04 PM
@HeyKen:  clever, but, I don't think that's the intended idea.  Rather, I suspect the goal is to merely check/uncheck the box directly and have something happen.

@Grinsekatze:  the problem with the checkbox, textbox is that these are OLE objects.  I don't know of a way to reference them directly in Visio.  Certainly not in the shapesheet.  Hence, Yacine's solution.  There must be code behind these items to have any direct impact.  That makes them problematic.  1).  Difficult to work with...lot developer related stuff.  2).  Code.  That means macros.  Not all companies allow macros for security reasons.

What Ken shows, is basically a shapesheet solution.  It provides the "visibility" of the control objects, but, avoids using any code.

Nevertheless, in keeping with what I think you're after, see attached.  Both check and text boxes are presented.  These are simple examples.  But, the code writes values to the page shapesheet.  The Visio shapes look at these values and determine what action to perform.  In the case of the textbox, values <=6 produce narrow line, > 6, <=24 produce fat line, >24 hide the line.

HTH
Wapperdude









Title: Re: ShapeSheet influenced by checkbox
Post by: Grinsekatze on August 16, 2017, 12:15:31 AM
Thanks a lot. I appreciate your help.
To change the ShapeSheet of the page is new to me.

@wapperdude: When I open your example, I can see the blue line but if I use the checkbox the line is always black. The solution would be perfect for me.

Right now, I am working a lot with the properties of my shapes to change the thickness and visibility. It doesn't feel smart to change the values in excel every time but it is working:D

Edit: @wapperdude: I got it:) Changed =IF(ThePage!Prop.checked>0,"RGB(0,0,255)","RGB(255,0,0)") to =IF(ThePage!Prop.checked>0,RGB(0,0,255),RGB(255,0,0))
thx;)