Show full version of the posting: SelectionSets Question

Silentwolf
16.09.2010, 13:42
Hi guys,I am Albert and I just became a member of this forum and I am completly new to AutoCad VBA so please be gentle with me :)As I like to get into Programming a little I looked on the net for some examples and found a small program to select layers in my drawing and then be able to change the drawing with an selected layer of a listbox.The code below shows what I got but when I make a selection in my list box  get an error ("The selection set exists")Here is the code.[code]Private Sub CommandButton1_Click()Dim Entity As ObjectDim ss As AcadSelectionSets'declare variable as local Me.Hide'hide the dialogue box Set ss = ThisDrawing.SelectionSets.Add("NEWSS")'create a selection set reference ss.SelectOnScreen'select the objects to change For Each Entity In ss'for every entity in the selection set     Entity.Layer = ListBox1.Text    'change the layer to the layer name    'selected in the list box    Next'process the next entity End'end the programme'declare variable as local Me.Hide'hide the dialogue box Set ss = ThisDrawing.SelectionSets.Add("NEWSS")'create a selection set reference ss.SelectOnScreen'select the objects to change For Each Entity In ss'for every entity in the selection set     Entity.Layer = ListBox1.Text    'change the layer to the layer name    'selected in the list box    Next'process the next entity End'end the programmeEnd Sub[/code]Could someone please let me know why it does not work or what I am missing?? I use AutoCad 2002.It would be nice to get an answer from you guys and it would be very much appreciated!ThanksAlbert