Hi. I pasted the following code from a help file, into a new .dvb file and ran it. I used to work fine. Currently it gives me an error (shown below). It used to work fine previously. I reinstalled ACAD and the VBA enabler. Still same. Not sure what to do.
Thanks in advance for any helpful advice.
~Robert
Sub RemoveMyLayer()
On Error Resume Next
'' Get the layer "MyLayer" from the Layers collection
Dim ABCLayer As AcadLayer
Set ABCLayer = ThisDrawing.Layers.Item("MyLayer")
'' Check for an error, if no error occurs the layer exists
If Err = 0 Then
'' Delete the layer
ABCLayer.Delete
'' Clear the current error
Err.Clear
'' Get the layer again if it is found the layer could not be removed
Set ABCLayer = ThisDrawing.Layers.Item("MyLayer")
'' Check for error, if an error is encountered the layer was removed
If Err <> 0 Then
ThisDrawing.Utility.prompt "'MyLayer' was removed"
Else
ThisDrawing.Utility.prompt "'MyLayer' could not be removed"
End If
Else
ThisDrawing.Utility.prompt "'MyLayer' does not exist"
End If
End Sub