Checking if value is defined localy in shape

Started by Nikolay, November 22, 2013, 12:01:28 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Nikolay

For each shapesheet cell, you can check if it's value is defined locally in shape using

shape.CellExists(<CellName>, True)

I thought this only returns true if cell exists in the shape locally.
But it turns out that this may also return true for cells, values of which do not actually exist locally, but are in fact inherited from master (those which are shown BLACK in the ShapeSheet)
I mean, when you e.g. modify a row in ShapeSheet, all cells from that row start returning "true" for Cellexists(<>, Tue)

The question is - is there a way to find out, if a cell value is defined locally (that the cell is "blue" in shapesheet?)

Thank you in advance!

Jumpy

The function seems to return wether the cell exists locally or not. It does not distinguish if the cells value exists locally or is inherited!

Nikolay

Quote from: Jumpy on November 22, 2013, 07:19:14 AM
The function seems to return wether the cell exists locally or not. It does not distinguish if the cells value exists locally or is inherited!

Yes, exactly - this was my problem.

It seems I found a way yesterday!
The Cell.InheritedFormulaSource seems to work. One down, two to go :)


Set cell = shape.Cells(<name>, True)
valueIsLocal = (cell = cell.InheritedFormulaSource)


I.e. if a cell is "blue" then "InheritedFormulaSource" is equal to the cell itself.
Honestly, Visio has really uncommon properties :)

JohnGoldsmith

Hello Nikolay,

Cell.IsInherited will also determine whether the formula is local or inherited (from a master or a style).  It depends on what you want to achieve though, because a cell's value might still be determined locally while the formula could be inherited (and the cell text color would remain black). 

For example, suppose you drop a shape based on a particular master - if the shape contains a cell with a master-defined formula that references another cell (such as PinX), which is local in the instance, then the InheritedFormulaSource would be a cell in the master and the InheritedValueSource would be the cell in the instance shape.

From what you're saying, though, I think you're just trying to work out if the formula is inherited or not, in which case either IsInherited or your cell equality check will work.

Best regards

John
John Goldsmith - Visio MVP
http://visualsignals.typepad.co.uk/

Nikolay

John, thank you for the clarification!

I just wanted to get the same behavior as in shape sheet - i.e. the "blue"/"black" color :)