About Migrating Automation Projects (VBA/ActiveX)

In general, an AutoCAD automation project created in the VBA IDE or created with Visual Studio might require some updates before it can be used in AutoCAD 2021.

For a general history of the changes made to the ActiveX API, see “ActiveX API History."

ActiveX Library References

References to the AutoCAD ActiveX API might need to be updated in VBA projects created in the AutoCAD drawing environment or other applications that support VBA, such as Microsoft Word or Excel. Managed .NET and ObjectARX applications that use the AutoCAD ActiveX API might also need to update.

The following table lists the filename of the AutoCAD object library that is supported by AutoCAD-based product release.

Release Release Number AutoCAD Type Library AutoCAD/ObjectDBX Type Library
AutoCAD 2021 R24.0 acax24<language>.tlb axdb24<language>.tlb
AutoCAD 2020 23.1 acax23<language>.tlb axdb23<language>.tlb
AutoCAD 2019 23.0 acax23<language>.tlb axdb23<language>.tlb
AutoCAD 2018 22.0 acax22<language>.tlb axdb22<language>.tlb
AutoCAD 2017 21.0 acax21<language>.tlb axdb21<language>.tlb
AutoCAD 2016 20.1 acax20<language>.tlb axdb20<language>.tlb
AutoCAD 2015 20.0 acax20<language>.tlb axdb20<language>.tlb
AutoCAD 2014 19.1 acax19<language>.tlb axdb19<language>.tlb
AutoCAD 2013 19.0 acax19<language>.tlb axdb19<language>.tlb
AutoCAD 2012 18.2 acax18<language>.tlb axdb18<language>.tlb
AutoCAD 2011 18.1 acax18<language>.tlb axdb18<language>.tlb
AutoCAD 2010 18.0 acax18<language>.tlb axdb18<language>.tlb
AutoCAD 2009 17.2 acax17<language>.tlb axdb17<language>.tlb
AutoCAD 2008 17.1 acax17<language>.tlb axdb17<language>.tlb
AutoCAD 2007 17.0 acax17<language>.tlb axdb17<language>.tlb
AutoCAD 2006 16.2 acax16<language>.tlb axdb16<language>.tlb
AutoCAD 2005 16.1 acax16<language>.tlb axdb16<language>.tlb
AutoCAD 2004 16.0 acax16<language>.tlb axdb16<language>.tlb
AutoCAD 2002 15.2 acax15.tlb axdb15.tlb
AutoCAD 2000i 15.1 acax15.tlb axdb15.tlb
AutoCAD 2000 15.0 acax15.tlb axdb15.tlb
Note: <language> represents the language of the object library. For example, <language> might be enu on English installations and fra on French installations.

The following lists filenames of the other AutoCAD ActiveX APIs used by earlier releases and the object library files that they have been replaced with the latest release:

New and Changed Objects in Latest Release

New Objects

No new objects were added.

Changed Objects

The following table describes the changes made to existing objects.

AutoCAD 2020 AutoCAD 2021 Description of change

AutoCAD.AcadLayerStateManager.23

AutoCAD.AcadLayerStateManager.24

Use AutoCAD.AcadLayerStateManager to create an instance of the AutoCAD Layer States Manager based on the latest library installed.

AutoCAD.AcCmColor.23

AutoCAD.AcCmColor.24

Use AutoCAD.AcCmColor to create an instance of an AutoCAD color object based on the latest library installed.

AutoCAD.Application.23 or AutoCAD.Application.23.1

AutoCAD.Application.24

Use AutoCAD.Application to create an instance of the AutoCAD application based on the latest library installed.

If you want to ensure an instance of AutoCAD 2021 is created, use AutoCAD.Application.24.

AutoCAD.SecurityParams.23

AutoCAD.SecurityParams.24

Use AutoCAD.SecurityParams to create an instance of an AutoCAD security parameters object based on the latest library installed.

General Changes from an Earlier Release

In addition to updating COM library references, the following changes might need to be made to migrate a program from an earlier release:

64-bit Migration

Starting with AutoCAD 2014, AutoCAD supports VBA 7.1 which offers native 64-bit support. This change will require you to maintain two versions of your VBA projects: 32-bit and 64-bit. In releases prior to AutoCAD 2014, VBA ran as an out-of-process component, accessed through a 32-bit-to-64-bit “thunking” layer which allowed existing 32-bit VBA projects to function as expected in AutoCAD 64-bit.

VBA 64-bit requires the use of different libraries and controls for forms. Not all VBA libraries and form controls are available in 64-bit yet, and you might need to adjust some of your code to work correctly on both Windows 32-bit and Windows 64-bit.

If your VBA projects were developed for AutoCAD 2009 through AutoCAD 2013, you need to take the following into consideration when migrating VBA projects to the latest release:

Handling ObjectId

Beginning with AutoCAD 2009 64-bit through AutoCAD 2013 64-bit, object IDs were represented by a 64-bit integer datatype (__int64). Accessing those values in 32-bit VBA caused a compilation error. As a resolution, a new set of method names suffixed with "32" corresponding to the old methods were created (e.g. ObjectID32(), OwnerID32()). Those methods used the LONG data type, which internally mapped to the 64-bit integer data type.

To be more precise, a 32-bit Object ID was created internally for each object ID required in VBA. This ID was mapped to its 64-bit actual ID, so that if the 32-bit ID was passed back to AutoCAD from VBA code, then the 64-bit object ID could be returned and used internally for all purposes.

The following sample gives an example of ported 32-bit Object ID code:

Original code 64-bit (AutoCAD 2009 through AutoCAD 2013)

Dim splineObj As AcadSpline
Dim objectID As Long
objectID = splineObj.objectID32
Dim tempObj As AcadObject
Set tempObj = ThisDrawing.ObjectIdToObject32(objectID)

Code ported for AutoCAD 2014 64-bit and later compatibility

Dim splineObj As AcadSpline
Dim objectID As Long
objectID = splineObj.objectID
Dim tempObj As AcadObject
Set tempObj = ThisDrawing.ObjectIdToObject(objectID)

VBA applications can also use an object’s handle instead of its object ID. The following sample shows how to use the handle instead of the object ID:

Original code using an object's Object ID

Dim splineObj As AcadSpline
Dim objectID As Long
objectID = splineObj.objectID
Dim tempObj As AcadObject
Set tempObj = ThisDrawing.ObjectIdToObject(objectID)

Revised code using an object's handle

Dim splineObj As AcadSpline
Dim objectHandle As String
objectHandle = splineObj.Handle
Dim tempObj As AcadObject
Set tempObj = ThisDrawing.HandleToObject(objectHandle)
Appendix of 32-bit Methods (Obsolete with AutoCAD 2014 64-bit and Later)
Note: Object IDs are no longer converted to the LONG data type for AutoCAD 32-bit.

The following table lists the methods that were used in AutoCAD 2009 64-bit through AutoCAD 2013 64-bit as 32-bit substitutions:

VBA Methods for a 64-bit System
Method - AutoCAD 2009 through 2013 Method - AutoCAD 2014 and Later Use
GetBlockAttributeValue32 GetBlockAttributeValue Returns the attribute value from the specified block cell for the attribute definition object contained in the block using its 32-bit object ID.
GetBlockTableRecordId32 GetBlockTableRecordId Gets the 32-bit object ID of the block table record associated to the block-type cell and nContent.
GetFieldId32 GetFieldId Returns the 32-bit object ID of the field object associated to the specified cell.
GetGridLinetype32 GetGridLinetype Returns the 32-bit object ID of the grid linetype object.
Key32 Key Specifies the object ID of the source object in the CopyObjects operation for a 64-bit system.
ObjectID32 ObjectID Gets the object ID for a 64-bit system.
ObjectIDtoObject32 ObjectIDtoObject Gets the object that corresponds to the given object ID for a 64-bit system.
OwnerID32 OwnerID Gets the object ID of the owner (parent) object for a 64-bit system.
SetBlockAttributeValue32 SetBlockAttributeValue Sets the attribute value from the specified block cell for the attribute definition object contained in the block and nContent using its 32-bit object ID.
SetBlockTableRecordId32 SetBlockTableRecordId Sets the 32-bit object ID block table record associated to the block-type cell and nContent.
SetFieldId32 SetFieldId Sets the 32-bit object ID of the field object associated to the specified cell and nContent.
SetGridLinetype32 SetGridLinetype Sets the 32-bit object ID of the grid line type object.
Value32 Value Specifies the current value for the property, or the object ID of the newly created cloned object, for a 64-bit system.