Q: Runtime error 424 With VBA to AutoCAD Code I want to draw in AutoCAD, using data from an Excel sheet, by VBA code. 
I found a code and ticked the references:


*

*AutoCAD Library 

*AutoCAD Object/DBX

*AutoCAD Focus for VBA


Here is the code to draw a circle:
Sub AddCircle()
    ' Define the center point
    Dim ptCen(0 To 2) As Double
    ptCen(0) = 2: ptCen(1) = 3: ptCen(2) = 0#

    ' Create a Circle object in model space
    Dim circObj As AcadCircle
    Set circObj = ThisDrawing.ModelSpace.AddCircle(ptCen, 4.25)

    ThisDrawing.Application.ZoomAll
End Sub

I got Runtime error 424. It seems that I missed some object.

A: To draw something in AutoCAD (must be opened) from Excel you must add reference Tools->References and add [AutoCAD 20xx Type Library]
and insert this in your code:
Dim app
On Error Resume Next
    Set app = GetObject(, "AutoCAD.Application")
On Error GoTo 0
If (app Is Nothing) Then Exit Sub

then refer to the active document
Dim doc
Set doc = app.ActiveDocument

now you can add circle with change ThisDrawing with doc
' Create a Circle object in model space
Dim circObj As AcadCircle
Set circObj = doc.ModelSpace.AddCircle(ptCen, 4.25)

doc.Application.ZoomAll

