TxtAngle

Started by novski, August 29, 2014, 05:09:55 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

novski

Hi
I tryed to set the Text angle in a User.xy formulae. But unfortunately it does not work.

What i whant is to make the Text of a connector turn by 90 deg with a shapedata dropdown.
I made a Prop.TxtMidAllign and set it to be the List of User.TxtMidAllign. Then Created a User.TxtMidAngleIndex as LOOKUP(Prop.TextMidAllign,User.TxtMidAllign,";") and then made a User.TxtMidAllignSet as IF(User.TxtMidAllignIndex=0,TxtAngle=90,0).
I also tryed this: IF(User.TxtMidAllignIndex=0,TxtAngle="90","0") as well as this: IF(User.TxtMidAllignIndex=0,TxtAngle=90 deg,0 deg).
The Index is switching to 0 if i click the dropdown Horizontal and to 1 if i Click Vertical. The text is positioned Vertical.

Instead something strange is happening with my toolbar.. All icons turn by 90°. Really weird.

Im Running Visio 2010 Standard on a Parallels 10 Virtual Win 7 Pro. Whats also unusual i think...

Does anybody have a clue whats going on?

Thanks a Lot
Novski

Yacine

Hi Novski,
you tried to do something obvious, but which doesn't exist in shapesheets: a direct assignment.
IF(User.TxtMidAllignIndex=0,TxtAngle=90,0) should be
User.TxtMidAllignSet = IF(User.TxtMidAllignIndex=0,90,0)
Angle=User.TxtMidAllignSet
OR:
User.TxtMidAllignSet = IF(User.TxtMidAllignIndex=0,setf(getref(angle,90)),setf(getref(angle,0)))

Cheers,
Yacine

Jumpy

Only to clarify Yacine's answer. He uses the angle cell. But everything he wrote applies to the txtangle cell, too.
And in the formula you have to use the "deg". Without it Visio uses afaik "rad".

So it should be:
User.TxtMidAllignSet = IF(User.TxtMidAllignIndex=0,90 deg,0 deg)
or maybe (don't remember and can't test at the moment):
User.TxtMidAllignSet = IF(User.TxtMidAllignIndex=0,"90 deg","0 deg")

Yacine

Yacine

novski

HI Jumpy & Yacine
Thanks for that help.
I don't understand the setf() and getref().
-But the User.TxtMidAllignSet=IF(User.TxtMidAllignIndex=0,90 deg,0 deg) works.

do you know why i got the Toolbar rotated by 90°? It also makes that in a page. Thats pretty weird...

best regards
novski

Yacine

QuoteI don't understand the setf() and getref().

Well that's actually the assignment, that you were trying to realise.
Yacine

novski

Hi Yacine

Now i get it.

the dok explanes it: http://msdn.microsoft.com/en-us/library/office/ff769152(v=office.14).aspx

In the Dok of getref() they write it does not recalculate the cell.

Is it possible that it will work slightly faster with this formulae from you:
User.TxtMidAllignSet =IF(User.TxtMidAllignIndex=0,setf(getref(TxtAngle,90)),setf(getref(TxtAngle,0)))

compared to the two formulae:
User.TxtMidAllignSet =IF(User.TxtMidAllignIndex=0,90 deg,0 deg)
TxtAngle=User.TxtMidAllignSet

best regards
Novski

Yacine

#7
I don't know. You can try to test it . You may duplicate the shape to an amount where speed matters and observe.

In your case, I would stick with the 2 formulas version ... without real justification, it is just simplier to read.

Don't forget however to add the the "deg", as Jumpy wrote.
Yacine

novski

Ok. I will test it with a bigger amount and two versions as soon i have a Finished version.

Thanks for the Help.
Novski

wapperdude

Couple things to note:
  1.)  First, like Yacine, cannot speak to the speed of execution, because you would need many repeated entries to see any speed difference
  2.)  Your formula using setf has syntax error:  formula should be =IF(User.TxtMidAllignIndex=0,SETF(GetRef(TxtAngle),90 deg),SETF(GetRef(TxtAngle),0 deg))
  3.)  This formula writes directly to the TxtAngle cell.  There is nothing actually written to the User.TxtMidAllignSet.  It is merely a holder for the formula.  This approach does control the TxtAngle cell value if that's all you want.

  4.) The two formula approach first writes the value into the User.TxtMidAllingSet, and then the TxtAngle cell.  I would think that this is slower. 

In fact, you could put the IF formula directly in the TxtAngle cell and skip the User.TxtMidAllingSet altogether, unless you reference it for other calculations.  Note, if you place it directly in the TxtAngle cell, the formula is vulnerable to being clobbered.  To avoid that, you need to either use Guard() function or the more complex SETATREF() approach.  Guard() might be a good choice if you want the TxtAngle controlled only by formula and want to prevent the User from manually making changes.

HTH
Wapperdude
Visio 2019 Pro

wapperdude

Whoops!  Forgot to add, that you can use a combined single statement and concurrently set values to both the TxtAngle and User.TxtMidAllignSet cells. 

Basically, you just catenate both formulas, so your User.TxtMidAllignSet cell would have this formula:  =IF(User.TxtMidAlignIndex=0,90 deg,0 deg)+IF(User.TxtMidAlignIndex=0,SETF(GetRef(TxtAngle),90 deg),SETF(GetRef(TxtAngle),0 deg)).

Then, for the most efficient formula, this works:  =IF(User.TxtMidAlignIndex=0,90 deg+SETF(GetRef(TxtAngle),90 deg),0 deg+SETF(GetRef(TxtAngle),0 deg)).  Yeah, it's a little difficult to read, but is quite compact.

So, if you need the "User...." cell, then this approach might offer the best speed.

Wapperdude
Visio 2019 Pro