Sample Code
 
 
 

This manual and the ActiveX and VBA Reference together contain over 800 example VBA subroutines that demonstrate the usage of ActiveX methods, properties, and events.

There are also many sample applications provided in the AutoCAD Sample directory. These sample applications show a wide range of fuctionality, from extracting AutoCAD drawing data into Microsoft Excel spreadsheets to drawing and performing stress analysis on an electrical transmission tower.

These samples also show how to combine the versatility of the Visual Basic for Applications programming environment with the power of the AutoCAD ActiveX interface to create customized applications.

Additionally, example code in the ActiveX and VBA Developer's Guide and ActiveX and VBA Reference can be copied from the Help files, pasted directly into the AutoCAD VBA environment, and then executed with one requirement: the current active drawing in AutoCAD must be a blank drawing open to model space.

To run the examples from the Help files

  1. Copy the example from the Help file into an empty VBA code module.
  2. Verify that AutoCAD has a blank drawing open to model space.
  3. Open the Macros dialog box by entering the command VBARUN.
  4. Choose the macro and press Run.

    More information on running macros and the Macros dialog box is available in the topic “Run a Macro.â€