How to run a vba routine from a custom button in autocad

How to run a vba routine from a custom button in autocad

Anonymous
Not applicable
526 Views
2 Replies
Message 1 of 3

How to run a vba routine from a custom button in autocad

Anonymous
Not applicable
I am able to do this once I have loaded in a dvb file using acad.lsp. The problem I have now is that I have loads of modules in one dvb file. Is it possible to make each module a separate file and have them load as an when required? or some other method where I dont have to worry about duplicating public variables or clashing subroutine names with module names etc...

Any help appreciated
0 Likes
527 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
The easiest way to do this is probably:

^c^c(command "vbarun" "c:\ExternalFile.dvb!Module1.MacroName")

This way you won't encounter any "already loaded" errors... no need to pass variables...
0 Likes
Message 3 of 3

dgorsman
Consultant
Consultant
I would create lisp file with a command-defined function for each macro call. Have the function check for the VBA arx and the module being loaded and load as necessary for error checking. Call the macro, then if you need to free space (for example, a macro that is seldom used) you can unload the dvb after the call is completed.

This "detaches" the process of which macro to call and where the dvb file is located from the CUI/MNS system. You can readily change what is being called by modifying the lisp without having to bugger around with editing the CUI/MNS files. It also allows the function to be called from the command line. Message was edited by: dgorsman
----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


0 Likes