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.


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"))


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"))


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


My Vote for

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