Count Existing Blocks In AutoCAD (VBA Add-In)

Share this

February 5, 2014

Counting Existing Blocks In AutoCAD VBA Add In


AutoCAD automation has been discussed several times in this blog. Various add-ins and VBA codes have been presented, mainly for drawing polylines and measuring lines’ length. Below you will find another useful VBA add-in that automatically lists all the blocks that exist in the active drawing. The add-in is, in reality, a form, containing a list box control, a text box and three buttons. When the Count Blocks button is pressed, the code loops through all the blocks of the active drawing. If a block is found, is added to the list box control. Moreover, in the text box, the total number of blocks will appear.


How to use it

  1. Open AutoCAD.
  2. In the command line write VBAMAN.
  3. Press the Load button in the menu that will appear.
  4. Use the browser window to find and open the Count Existing Blocks.dvb file.
  5. Choose the Enable Macros button and then press the Macros button.
  6. At the macros menu, select the CountBlocks macro and press the Run button. A form will appear (see the figure above).
  7. Press the Count Blocks button and the list box will be populated with all the blocks that exist in the active drawing. The text box below the list box will contain the total blocks.
  8. Finally, if you press the Export To Excel button, a new workbook will be created containing all the data from the list box and the text box.
  9. If you have closed the form and want to re-use it you don’t have to reload the file. You can simply write VBARUN at the command line and continue the procedure from step 6.

Note: If you have AutoCAD 2010 or a newer AutoCAD version, download the VBA module from Autodesk’s site before using this add-in.


Demonstration video

The short video below shows you how to load and use the add-in.


Manual alternatives

There are two different “manual” solutions regarding block counting. The first one involves the command BCOUNT, while the other the Data Extraction tool (more complicated solution). Below you will find some guidelines about how to “manually” count blocks in AutoCAD (without using the above tool).

Using the BCOUNT (block count) command


  1. In the command line write BCOUNT.
  2. Select an area that contains the blocks you want to count.
  3. Press Enter (or click the right button of your mouse). In the command line window, the block names and the instances will appear.
  4. Select and copy the results to a new workbook.

Using the Data Extraction tool

Using Data Extraction Tool

  1. In the command line write EATTEXT. The data extraction wizard will start, containing 8 pages/steps.
  2. In the form that will appear choose the Create a new data extraction radio button and press the Next button (page 1 of 8).
  3. Select the folder where you want to save the new .dxe file, give it a meaningful name and press the Save button.
  4. Choose the Drawings/Sheet set radio button, check the Include current drawing checkbox and press the Next button (page 2 of 8).
  5. Uncheck the Display all object types checkbox, choose the Display blocks only radio button, check the Display objects currently in-use only checkbox and press the Next button (page 3 of 8).
  6. There are various properties you can extract by checking the appropriate checkbox. For the particular example, use the Category filter to uncheck all the categories except the General category and press the Next button (page 4 of 8).
  7. Leave all the checkboxes enabled and press the Next button (page 5 of 8).
  8. Check the Output data to external file checkbox and specify the location, the type and the name of the output (.xls, .csv, .mdb, .txt) file. Press the Next button (page 6 of 8).
  9. Finally, press the Finish button (page 8 of 8). Then, find the output file and open it. It would probably look like the image below.

Extracted Results

Up until now, you learned 2 + 1 different ways to count the blocks in a drawing, so you can choose the solution that best fits your needs!




The file was created and tested with AutoCAD 2013, but it will probably work in either older or newer AutoCAD versions.


Read also 

Insert Blocks In AutoCAD Using Excel & VBA
AutoCAD VBA Add-In: Calculate Polylines Length & Area

Page last modified: October 2, 2021

Christos Samaras

Hi, I am Christos, a Mechanical Engineer by profession (Ph.D.) and a Software Developer by obsession (10+ years of experience)! I founded this site back in 2011 intending to provide solutions to various engineering and programming problems.

  • Naveena,

    Thanks for pointing out the error.
    I just corrected the file, so it should work now.
    I tested it on AutoCAD 2021 without a problem.

    Best Regards,

  • hii iam using autocad version 2021 and when iam running this macro iam getting error like object doesnt support this property will you help me out with it

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
    Add Content Block