16
Moderator
#1
AutoCAD Drawing automation techniques using VBA (Visual Basic for Applications)

AutoCAD VBA Introduction

VBA Stands for Visual Basic for Applications, where program snippets used to control the applications instead of commands/controls. You can use VBA Editor to add new codes, modify existing codes. All codes are written in familiar programming language VB and since this website deals with VBA for AutoCAD, Excel and Solidworks, it is recommended that you refer VB code tutorials (there are many, available online) before using this website.
VBA Editor comes with AutoCAD 2007 version as preinstalled, if you are using later versions; you should install VBA editor before beginning the projects.
To open VBA Editor, go to Tools -> Macro -> Visual Basic Editor as shown below

Or simply press ALT + F11
[Image: 1.JPG]

The newly opened window should be something like this,
[Image: 2.JPG]
To begin with your first vba macro, go to Insert -> Module

[Image: 3.JPG]
Then type Sub module1 () and press Enter (module1 is the name of your new module, it can be anything like drawline, yourname etc without any spaces)
As you can see that “End Sub” has been appeared just below Sub module1 (), thus defining the boundary of your AutoCAD macro.
Now, you can start typing your codes between module name and end sub, ie, Sub module1 () and End Sub, as shown below

 Sub module1()
  'your codes goes here
  'your codes goes here
  'your codes goes here
 End Sub
Reply


0
Junior Member
#2
how to enable developer tab for autocad

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)