I 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).