Macro always available

Macro always available

Anonymous
Not applicable
692 Views
10 Replies
Message 1 of 11

Macro always available

Anonymous
Not applicable
I'm losing the plot a bit here!

I've used VBA in ACAD 2004 to create a macro (and it works).
I've added to the menu so the macro can be run from there.
Where do I save the macro so it's always available when I fire up ACAD and start a new drawing??

(Probably obvious, but I'm new to using VBA in ACAD)
0 Likes
693 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable
Save your VBA project as a .dvb file. In order to run the VBA macro you need to have the .dvb project loaded (you probably already know this part), so you must load it using the VBALOAD command. You can easily just load it each time you re-open autocad, and have a tool referring to the macro you want (using VBARUN).

If you want the command to be available from opening AutoCAD, you need the dvb file to be loaded on startup of AutoCAD. The way I do this is using the acad.lsp file which runs on startup. Simply place in the following lisp code (create acad.lsp if it does not already exist) and point the URL to the location of your .dvb file.

(command "vbaload" "C:\\CAD\\PROJECT.DVB")

note the double forward slashes - in lisp the \ is a special character, so you must use two of them. Message was edited by: RaNDoM
0 Likes
Message 3 of 11

Anonymous
Not applicable
I'm just going to clarify myself because i was a bit unclear in the first post:

1, Create your macro.
2, Save it from the VB editor as a .dvb file.
3, Create (or edit) acad.lsp located in C:\Program Files\AutoCAD 2007\Support (assuming 2007)
4,place in this code: (command "vbaload" "C:\\CAD\\PROJECT.DVB") keeping the brackets, and pointing the URL to the location of your .dvb file.
5, create a tool for your toolbar (sounds like you've already done this) pointing to the macro you wish to run using VBARUN MacroName.

Hope this helps
0 Likes
Message 4 of 11

Anonymous
Not applicable
Many thanks.

The use of the "double backslash" caught me!!
0 Likes
Message 5 of 11

Anonymous
Not applicable
It caught me too when i first did it!

Glad to help.

RaNDoM
0 Likes
Message 6 of 11

arcticad
Advisor
Advisor
Also a file named acad.dvb in your path is automatically loaded.
---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes
Message 7 of 11

Anonymous
Not applicable
I've also found that you can add the .dvb to the "Startup Suite".
0 Likes
Message 8 of 11

Anonymous
Not applicable
Hi Peter,

What is the point of loading a DVB at startup?

The command VL-VBARUN will run the macro - loading it if necessary. That
way you don't need to use resources on the macro till you actually need to
use it - and if you don't use it during the working session, then you
haven't wasted any time with it at all.

--

Laurie Comerford
CADApps
www.cadapps.com.au
www.civil3Dtools.com

wrote in message news:5496842@discussion.autodesk.com...
I've also found that you can add the .dvb to the "Startup Suite".
0 Likes
Message 9 of 11

Anonymous
Not applicable
Just pointing out another way to "skin the cat".
0 Likes
Message 10 of 11

Anonymous
Not applicable
The command VL-VBARUN doesnt exist on my machine
0 Likes
Message 11 of 11

Anonymous
Not applicable
Hi,

It need to be proceeded by a once per session only (vl-load-com) to load the
Visual Lisp environment.
It available in every version of AutoCAD with Visual Lisp.
It is invoked as I indicated:

(vl-vbarun FileSpec.dvb!MacroName)

If after all that, it still doesn't show up, I'd suggest taking the computer
to the Washington National Museum for display as being one capable of
installing half a program while appearing to install it all.

--

Laurie Comerford
CADApps
www.cadapps.com.au
www.civil3Dtools.com
wrote in message news:5497703@discussion.autodesk.com...
The command VL-VBARUN doesnt exist on my machine
0 Likes