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 2016.

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 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 2015 AutoCAD 2016 Description of change

IAcadSection

IAcadSection2

Use IAcadSection2 to use the new properties.

IAcadDocument

IAcadDocument

The SaveAs method no longer supports the ability to assign a password to a drawing file. Attempts to password protect a drawing file results in an error. Update code statements that contain the SaveAs method and is passed an IAcadSecurityParams object as needed.

IAcadSecurityParams

IAcadSecurityParams

The Algorithm, KeyLength, Password, ProviderName, and ProviderType properties are obsolete. Projects using these properties must be updated.

The Action property no longer accepts the ACADSECURITYPARAMS_ENCRYPT_DATA and ACADSECURITYPARAMS_ENCRYPT_PROPS constants or their equivalent values.

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:

AutoCAD Object Instantiation in VBA

64-bit operating systems can execute both 32-bit and 64-bit applications, but they cannot mix these types within a process. For example, you cannot load 32-bit DLLs into a 64-bit process, or vice versa. All executable components (EXE and DLL files) that are loaded into a process must match the binary type of the process. In-process components for your 64-bit applications should be ported to 64-bit processes as much as possible.

One error could occur when attempting to create a new object. VB’s New keyword will attempt to load 64-bit AutoCAD COM DLLs. Since VBA is a 32-bit application, it cannot load 64-bit DLLs. For example, code such as

Dim color As AcadAcCmColor
Set color = New AcadAcCmColor

or

Dim color As New AcadAcCmColor
color.SomeMethod()

needs to be modified and ported to

Dim color As AcadAcCmColor
Set color = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.20")

The above issue should be resolved using AcadApplication.GetInterfaceObject("ProgIdOfAcAnyObject") for any object that is derived from IDispatch. Classes derived from IUnknown (e.g. AcSmSheetSet, AcSmSheetMgr etc) are not expected to have a 64-Bit VBA migration. It is recommended that you port such processes to VB.NET.

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 are represented by a 64-bit integer datatype (__int64). Accessing these values in 32-bit VBA will result in a compilation error. As a resolution, a new set of method names suffixed with "32" corresponding to the old methods are used (e.g. ObjectID32(), OwnerID32()). These methods use the LONG data type, which internally maps to the 64-bit integer data type.

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

Note: Object IDs are no longer converted to the LONG data type for AutoCAD 32-bit.

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.