Author Topic: Manipulating a shape from another shape  (Read 6513 times)

0 Members and 1 Guest are viewing this topic.

Crazy Squirrel

  • Jr. Member
  • **
  • Posts: 27
Manipulating a shape from another shape
« on: November 18, 2021, 03:57:40 AM »
Ok, so I have two boxes.  Box 1 is red and box 2 is white. 
When I input the letter "Y" into box 1, I would like it to turn green. If I input the letter "N" into box 1, I would like it to turn white.
If box one has the letter "Y" and has turned green, I would then like box 2 to turn red until text is entered and it too will then turn green.
It is for a form to indicate further information is required in the adjacent box if Y is inputted.

Hope that makes sense!

vojo

  • Hero Member
  • *****
  • Posts: 1711
Re: Manipulating a shape from another shape
« Reply #1 on: November 18, 2021, 08:28:12 AM »
within a shape:   Easy...for example
fillforegrnd = if(strsame(props.letter, "Y"),<green>, if(strsame(props.letter,"W",<Gray",)   ///last clause means do nothing

Between shapes:  Can be hard
- if shapes have fixed relationship (in a group, in a container, etc), can leverage above
- if shape dont have fixed relationship, then very difficult  to do....visio does not have shape discovery
   (one can no, without VBA, go find other shapes in the drawing via id or handle)

Crazy Squirrel

  • Jr. Member
  • **
  • Posts: 27
Re: Manipulating a shape from another shape
« Reply #2 on: November 18, 2021, 01:34:39 PM »
Thanks vojo.

Adding more than one IF statement is making my box either not change colour or change to black regardless of the colour I specify.

Combinations I've tried so far:-

=IF(STRSAME(Prop.letter,"Y"),3,1)=IF(STRSAME(Prop.letter,"N"),2,1)=IF(STRSAME(Prop.letter,""),2,1) - Stays white

=IF(STRSAME(SHAPETEXT(TheText),"N"),3,2)=IF(STRSAME(SHAPETEXT(TheText),"Y"),3,2) - White with no input, black with any text inserted

=IF(STRSAME(SHAPETEXT(TheText),"N"),2,3) - Red when "N" inputted but stays green at all other times.  Would like a third option.

Any help would be much appreciated.



Crazy Squirrel

  • Jr. Member
  • **
  • Posts: 27
Re: Manipulating a shape from another shape
« Reply #3 on: November 18, 2021, 04:48:51 PM »
UPDATE...

I've sorted the three colour problem

=IF(STRSAME(SHAPETEXT(TheText),"Y"),3,IF(STRSAME(SHAPETEXT(TheText),"N"),1,IF(STRSAME(SHAPETEXT(TheText),""),2,1)))

Now just need to link the boxes so if box 1 has a "Y" and tuns green, box 2 needs to turn red.

It's not going to happen is it!!

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4882
  • Ideas Visio-lized into solutions
Re: Manipulating a shape from another shape
« Reply #4 on: November 18, 2021, 07:28:44 PM »
Here's reference on formula structure within the shapesheet:  https://docs.microsoft.com/en-us/previous-versions/office/developer/office-xp/aa200961(v=office.10)  This shows how to reference cells in another shape...which is what you want to do.

To use this, you need to know the identity of the box1 shape, i.e., sheet.X, where X is a number.  Assuming that box1 was the 1st shape on the page, it would be sheet.1.  So, your box2 formula would be.. IF(STRSAME(sheet.1!SHAPETEXT(TheText),"Y"),<red>,<gray>), where you must provide the red and gray definitions.



Visio 2019 Pro

Crazy Squirrel

  • Jr. Member
  • **
  • Posts: 27
Re: Manipulating a shape from another shape
« Reply #5 on: November 19, 2021, 05:59:07 AM »
Thanks wapperdude.

Unfortunately it keeps giving me an error from (TheText).

=IF(STRSAME(sheet.1060!SHAPETEXT(TheText),"Y"),2,3)

Any ideas?

Surrogate

  • Hero Member
  • *****
  • Posts: 1836
    • ShapeSheet™ Knowledge Base
Re: Manipulating a shape from another shape
« Reply #6 on: November 19, 2021, 06:23:33 AM »
Any ideas?
Code
IF(STRSAME(SHAPETEXT(sheet.1060!TheText),"Y"),2,3)
Please read more about cell references !
« Last Edit: November 19, 2021, 07:39:52 AM by Surrogate »

vojo

  • Hero Member
  • *****
  • Posts: 1711
Re: Manipulating a shape from another shape
« Reply #7 on: November 19, 2021, 08:57:20 AM »
use lots of user cells

user cell 1 = if(<check1>, true, false)
user cell 2 = if (check2>), true, user.cell1)
user cell 3 = if(<check3>),true,user.cell2)
...
user cell N = if(<check n>,true,user.celln-1)

etc

easier to debug

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4882
  • Ideas Visio-lized into solutions
Re: Manipulating a shape from another shape
« Reply #8 on: November 19, 2021, 10:13:30 AM »
Oops.  Thanks Surrogate for catching the error.
Visio 2019 Pro

Crazy Squirrel

  • Jr. Member
  • **
  • Posts: 27
Re: Manipulating a shape from another shape
« Reply #9 on: November 30, 2021, 04:47:44 AM »
Thanks Surrogate.  I'd like to get a bit more technical!
Now that box 2 has turned red to indicate input is required, can I make it change to green once text has been entered?  Possilbly a then or else funcuntion?  (Still need the Y in box 1)

Surrogate

  • Hero Member
  • *****
  • Posts: 1836
    • ShapeSheet™ Knowledge Base
Re: Manipulating a shape from another shape
« Reply #10 on: November 30, 2021, 05:01:22 AM »
Possilbly a then or else funcuntion?  (Still need the Y in box 1)
You can use multiple nested IFs

Crazy Squirrel

  • Jr. Member
  • **
  • Posts: 27
Re: Manipulating a shape from another shape
« Reply #11 on: November 30, 2021, 06:09:29 AM »
My first "IF" seams to be overwriting the others.  Could you have a look at it for me please?

=IF(STRSAME(SHAPETEXT(Sheet.1000!TheText),"y"),2,
IF(STRSAME(SHAPETEXT(Sheet.1000!TheText),"n"),1,
IF(STRSAME(SHAPETEXT(Sheet.1000!TheText),"Y"),2,
IF(STRSAME(SHAPETEXT(Sheet.1000!TheText),"N"),1,
IF(STRSAME(SHAPETEXT(Sheet.1000!TheText),"-"),1,
IF(STRSAME(SHAPETEXT(TheText),""),1,RGB(80,200,250)))))))

Surrogate

  • Hero Member
  • *****
  • Posts: 1836
    • ShapeSheet™ Knowledge Base
Re: Manipulating a shape from another shape
« Reply #12 on: November 30, 2021, 06:25:13 AM »
I am sorry, i am Russian.
I may have misunderstood the task!
« Last Edit: November 30, 2021, 06:35:24 AM by Surrogate »

Crazy Squirrel

  • Jr. Member
  • **
  • Posts: 27
Re: Manipulating a shape from another shape
« Reply #13 on: November 30, 2021, 09:08:36 AM »
Awesome Surrogate, thank you.
I didn't need the drop down on shape data but managed to get it working with what was entered.  I'm sure you guys would have a more simpler way of doing this.

=IF(LEN(SHAPETEXT(TheText))>0,4),
IF(STRSAME(SHAPETEXT(Sheet.1000!TheText),"y"),2,
IF(STRSAME(SHAPETEXT(Sheet.1000!TheText),"n"),1,
IF(STRSAME(SHAPETEXT(Sheet.1000!TheText),"Y"),2,
IF(STRSAME(SHAPETEXT(Sheet.1000!TheText),"N"),1,
IF(STRSAME(SHAPETEXT(Sheet.1000!TheText),"-"),1,1))))))

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4882
  • Ideas Visio-lized into solutions
Re: Manipulating a shape from another shape
« Reply #14 on: November 30, 2021, 09:40:44 AM »
For your scenario, the 1st IF would be the final result, and then work backwards in priority. Basically, reverse your order.

If there is a long concatenation, I would recommend using Visio's suggested method of putting each IF in a separate User entry.  It really helps for debugging and understanding, especially at a much later date.  Then, your construct becomes merely creating a conditional statement using the User row results.

Visio 2019 Pro