Cell.Precedents throws an exception

K

Kari Yli-Kuha

Hi all,

I noticed a Prop.Cell.Value peculiarity.

Regardless of property type, if Prop.Value has "No Formula" the calls to the cell's
Precedents property throw an "unexpected end of file" exception.

The behaviour is the same in C#/.NET and macro (VBA) environments.

The Macro1 in the example demonstrates the situation:

http://www.sqc.fi/~ylikuka/Visio/TestCellPrecedents.vsd

is this a known bug or a feature?

rgrds,
/C
 
J

John Goldsmith_Visio_MVP

Hello C,

That's interesting.

The default property for the cell object is Result, which is what you'd
normally use to get a value. I guess this is an evaluted result which takes
in a formula.

Anyway you could check the formula property first and only check the
Precendents property if you discover a formula. For example:

Sub GetPrecedents()
Dim shp As Shape
Set shp = ActiveWindow.Selection.PrimaryItem
If Not shp Is Nothing Then
Dim vCell As Cell
If shp.CellExistsU("Prop.Row_1", 0) Then
Set vCell = shp.Cells("Prop.Row_1")
If vCell.FormulaU = "" Then
Dim PrecedentCells() As Visio.Cell
PrecedentCells = vCell.Precedents
'Iterate through you precendents array here
End If
End If
End If
End Sub

Best regards

John


John Goldsmith (Visio MVP)
www.visualSignals.typepad.co.uk
www.visualSignals.co.uk
 
K

Kari Yli-Kuha

Thanks John,

As a workaround I'm using try/catch (C#/.NET) which works just as well.

BTW. the Visio bug is both in Visio11 and Visio12 - haven't tried older ones.

regards,
/C
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top