Posted same question in http://www.experts-exchange.com/jsp/qManag…mp;qid=20336203%5B/url%5D
I am creating some Shapes as even Visio 2000 does not have them.
I seem to have stumbled over a bug ..er.. feature for which I do not find a reference in whole (accessible) internet:
If the distance between the nodes is below approx. 8 points the VBA is soured to the point an Excel restart is needed.
Here my questions:
a) Did you ever encounter this ?
Please test the following code on your machine:
– Make sure no open _work_ is left unsaved
– Please run my sub first with a=8
– Paste the string here containing the Excel version / Operating System as written into the active cell of your test worksheet
– Re-run macros with diminishing values for ‘a’ until you get an application error
– Try with the _previous_ last ‘a’
in my case the ConvertToShape method will not work anymore, I need to restart Excel, merely resetting is not sufficient
Sub MinimalNodeDistance() Const a As Single = 8 'will crash if < 8, 'souring' the ConvertToShape method Const x0 As Single = 50 Const y0 As Single = 50 With Application ActiveCell = "Excel " & .Version & " (Build " & .Build & "), _ running on " & .OperatingSystem End With With ActiveSheet.Shapes.BuildFreeform(msoEditingCorner, x0, y0) .AddNodes msoSegmentLine, msoEditingAuto, x0 + a, y0 .AddNodes msoSegmentLine, msoEditingAuto, x0 + a, y0 + a .AddNodes msoSegmentLine, msoEditingAuto, x0 + 2 * a, y0 + a .AddNodes msoSegmentLine, msoEditingAuto, x0 + 2 * a, y0 + 2 * a .AddNodes msoSegmentLine, msoEditingAuto, x0 + 3 * a, y0 + 2 * a .ConvertToShape.Select End With End Sub