On Error GoTo err
'----------find AutoCAD application------------------
Dim poAcad As Object 'Autocad.AcadApplication
Set poAcad = GetObject(, "AutoCAD.Application")
Set poAcad = GetObject(, "AutoCAD.Application")
poAcad.Visible = True
Set acadDoc = poAcad.ActiveDocument
'--------------------------------------------------------------------------
'Scan the AutoCAD layer list and look for standard RGB color values
Dim layerNames As String
Dim layerColors As String
ctr = 0
layerColors = ""
layerNames = ""
For Each entry In acadDoc.layers
Text1.Text = entry.Name 'display current layer name in text box
'Grab RGB Layer color and Convert to AutoCAD 255 Index Colors (ACI)
AColor = acadDoc.layers(entry.Name).Color
Set Layerobj = acadDoc.layers.Add(entry.Name)
Layerobj.Color = AColor
Text1.Refresh 'redraw text box
ctr = ctr + 1 'start counter to count number of layers
Next
Text1.Text = ctr & " Layers Converted"
Beep
GoTo pau
err:
'If err Then 'MsgBox Err.Description
er = MsgBox("Can't find AutoCAD, Please verify that AutoCAD is Open and try again." & vbCrLf & err.Description & ". Error: " & err.Number, vbInformation, "AutoCAD Instance Not Found!")
pau:
'end---------------------------------------------