My last example must have slipped past you ...
Private Sub CommandButton1_Click()
'Allows user to pick entity that contains desired layer
Dim objDrawingObject As AcadEntity
Dim varEntityPickedPoint As Variant
Dim NewLayer As AcadLayer
Me.Hide
'On Error Resume Next
ThisDrawing.Utility.GetEntity objDrawingObject, varEntityPickedPoint, _
"Choose object to take layer
from: "
If objDrawingObject Is Nothing Then
MsgBox "You did not choose an object"
Exit Sub
End If
'change active layer to that of the object selected
Set NewLayer = ThisDrawing.Layers(objDrawingObject.Layer)
ThisDrawing.ActiveLayer = NewLayer
End Sub
Be carefully how you use On Error Resume Next
wrote in message news:[email protected]...
I'm struggling a bit. I am using a combination of Mr Sutphins book (very
good BTW) and also my own trial and error.
The following seems to always return the MsgBox before I select the
entity......sorry if I'm being annoying 😞
Private Sub CommandButton1_Click()
'Allows user to pick entity that contains desired layer
Dim objDrawingObject As AcadEntity
Dim varEntityPickedPoint As Variant
On Error Resume Next
ThisDrawing.Utility.GetLayer objDrawingObject, varEntityPickedPoint, _
"Choose object to take layer
from: "
If objDrawingObject Is Nothing Then
MsgBox "You did not choose an object"
Exit Sub
End If
ThisDrawing.ActiveLayer = objDrawingObject
End Sub