-2147467259 Method 'Count' of object 'IAcadSelectionSet' failed
This bug in AutoCAD causes this
and similar errors with AcadSelectionSet when
the code is run immediately after issuing the
OPEN command and then cancelling it.
Anyone have a work around?
Public Sub ConvertText2Mtext(Optional intUsePrevious As Integer)
Dim ssText As AcadSelectionSet
Dim ssPrev As AcadSelectionSet
Dim objAcTxt As Object
Dim objAcTxt2(0 To 0) As Object
Dim acText As AcadText ' i added
Dim acMtext As AcadMText ' i added
On Error GoTo Err_Control
myZ = 0
intActiveSpace = ThisDrawing.ActiveSpace
'///Since this set is temporary, switched to PF
Set ssText = ThisDrawing.PickfirstSelectionSet
If intUsePrevious = 1 Then
'Set ssPrev = ThisDrawing.SelectionSets.Add("TEST_SELECTIONSET")
Set ssPrev = ThisDrawing.PickfirstSelectionSet
ssPrev.Select acSelectionSetPrevious
For Each objAcTxt2(0) In ssPrev 'CRASHES HERE
If TypeOf objAcTxt2(0) Is AcadText Then
ssText.AddItems objAcTxt2
End If
Next
Else
if you draw something in a blank drawing. Then type OPEN at the command prompt and then close the OPEN FILE DIALOG without picking a drawing. Then run a selection set routine, it crashes. YOu have to restart autocad to get the selection sets working again. I know, don't cancel the open dialog. But my users did not like that answer. ANybody know a fix?