Simple selection,but dont work

Simple selection,but dont work

Anonymous
Not applicable
254 Views
1 Reply
Message 1 of 2

Simple selection,but dont work

Anonymous
Not applicable
Hello form Italy.
I've make a simple routine for make a new selection
and erase them. The first selection work fine but in
the second the VBA get a error -2147417848 and AutoCAD crash!!!
Please why?

Private Sub CommandButton1_Click()

Dim SelObj As AcadSelectionSet

'INIZIO
UserForm1.Hide

'SELEZIONE
For Each SelObj In ThisDrawing.SelectionSets
SelObj.Delete
Next

Set SelObj = ThisDrawing.SelectionSets.Add("Element")
SelObj.SelectOnScreen

'END
UserForm1.Show

End Sub
0 Likes
255 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
try this
Dim SelObj As AcadSelectionSet
UserForm1.Hide
On Error Resume Next
For Each SelObj In ThisDrawing.SelectionSets
SelObj.Delete
Exit For
Next SelObj

Set SelObj = ThisDrawing.SelectionSets.Add("Element")
SelObj.SelectOnScreen
SelObj.Delete

UserForm1.Show

John Jin
0 Likes