News:

BB code in posts seems to be working again!
I haven't turned on every single tag, so please let me know if there are any that are used/needed but not activated.

Main Menu

Setting Shapesheet value twice with VBA

Started by TwoBeAss, March 07, 2024, 10:45:37 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

wapperdude

#15
Ah.  Use Boolean conversion. 

I tried: vShp.Cells("User.Row_1").ResultIU = Not CBool(vShp.Cells("User.Row_1").ResultIU)
  Unfortunately, that also returned "-1".  If exchange order of Not and CBool, CBool(Not(vShp.Cells("User.Row_1").ResultIU)), still get -1.

I have mixed feelings about the "-1".  I like the simplified syntax.  But, the result is not really a Boolean value.  Not sure why it doesn't throw an error or exception.  Perhaps, someday it might.  Having said that, I cannot recommend using an approach that generates a non-Boolean value where the user might expect to get one.  So, user beware. 

Visio 2019 Pro

Thomas Winkel

I guess writing into ResultIU converts to a number.
Writing into Formula seems to work well.

shp.Cells("Prop.Test").Formula = Not CBool(shp.Cells("Prop.Test"))

wapperdude

That's odd.

I tried each of the following, and all produced same result, -1

        vShp.Cells("User.Row_1").Formula = Not vShp.Cells("User.Row_1").ResultIU

'        vShp.Cells("User.Row_1").ResultIU = Not CBool(vShp.Cells("User.Row_1").ResultIU)

'        vShp.Cells("User.Row_1").Result("") = Not vShp.Cells("User.Row_1").Result("")

'        vShp.Cells("User.Row_1").Formula = Not vShp.Cells("User.Row_1").Result("")
Visio 2019 Pro

Thomas Winkel

Agree, but that works:

vShp.Cells("User.Row_1").Formula = Not CBool(vShp.Cells("User.Row_1"))

wapperdude

#19
Ooops.  Had a typo.  Yes, that last construct yields proper boolean
Visio 2019 Pro

TwoBeAss

My Vote for

If vShp.Cells("User.Row_1").ResultIU Then

Browser ID: smf (possibly_robot)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 236 (show)
Files included: 32 - 1207KB. (show)
Memory used: 1095KB.
Tokens: post-login.
Cache hits: 13: 0.00176s for 26,722 bytes (show)
Cache misses: 3: (show)
Queries used: 16.

[Show Queries]