Andi Allan
Andi Allan

Reputation: 35

CALLTHIS on shapesheet not firing reliably - multiple shapes at the same time

enter image description hereI have a macro-enabled stencil for audio-visual schematic drawings, which includes a rack frame shape for when the team is doing a 19" rack layout. By default this is 1U tall, but when dragged up it expands, up to 47U (the biggest rack we commonly use).

Next to each U is a marker (a square shape) to show that rack U's number - from 01 at the bottom up to 47 at the top. There are formulas on the shape sheet to hide these (behind the 01 marker) when the rack isn't as tall as their position, and to make them visible and move them into place as the rack expands. This all works.

I have been trying to solve an issue where a user might delete the body of the rack but not the markers, which leaves invisible and visible markers behind. I've approached this by adding a formula to a user-defined cell on each marker's shapesheet, which wraps an iferror function around a reference to the rack body. When the rack body is deleted, the iferror function calls a "DeleteMe" sub in the stencil's VBA code.

The function I'm using on the shapesheet is:

=IFERROR(IF(RackBody!Width>20 mm,TRUE,TRUE),CALLTHIS("ThisDocument.DeleteMe","AV_Symbols_24"))

So the If statement always resolves to True, except if RackBody has been deleted, when it makes an error, firing the CALLTHIS function. The DeleteMe sub has one line:

Sub DeleteMe(vsoShp as Visio.Shape)
    vsoShp.delete
End Sub

However, when I delete the RackBody shape, not all of the markers get deleted - despite them all having exactly the same function. I added a debug.print call to the code, and it fires for the first 65 markers (always the same ones, and always ones with the 65 lowest shape id numbers). If I comment out the delete line, the debug.print fires for all 94 markers.

My suspicion is therefore that each deletion takes a bit of time, and by the time the first 65 have fired, the rest get missed by Visio, but I'd be interested if anyone has any further insight. For the moment I have restricted the rack height to 27U which works reliably (and I have a facility to let you put a second rack next to it, starting at 28U).

Upvotes: 0

Views: 88

Answers (1)

Surrogate
Surrogate

Reputation: 1734

The function I'm using on the shapesheet is:

=IFERROR(IF(RackBody!Width>20 mm,TRUE,TRUE),CALLTHIS("ThisDocument.DeleteMe","AV_Symbols_24"))

Please check picture below

CALLTHIS

Also look at IFERROR function.

Returns the evaluated result of a primary expression, if it does not evaluate to an error. Otherwise, returns the evaluated result of an alternate expression

IFERROR(primary expression, alternate expression )

primary expression is expression formula (string) which can fired error. In your case formula is correct (no error).


Quote from this thread's comments

but has the same limitation on how many times

Visio have some limitations like

Mark Nelson (MS) says (JUNE 17, 2007 AT 3:42 AM):

As best as I can determine, the reason that 2-D glue breaks after 10 shapes is that it technically relies on a circular reference in the Shapesheet to achieve the result. Visio has a hard-coded limit on the number of recalc iterations it will use when attempting to resolve circular references. This limit is 40, which is a multiple of 10. I have not gotten an exact explanation about the relationship though.

These limitations are different for MS Visio versions (2007/2010/2013/2016 and newer).

Upvotes: 0

Related Questions