I'm a little new to VBA programming and customization and I'm having trouble with something. I wrote a VBA macro (in its own module) but the only I know to call it is with the run VBA dialog box (VBARUN command) selecting it from the list.
I am wondering if there is a way to create a unique command name for it so I can call it directly from the command line, or if I can create a button to call it from my custom tool pallette. Thanks for any help.
Caleb B
(defun C:HB () (vl-load-com) (vl-vbarun "HotButton2010.dvb!HBMain") (princ) )
I have the above in my acaddoc.lsp
This defines a command HB. When run on the command line it loads the vba file HotButton2010.dvb and run the sub HBMain from within that file.
In this case the acaddoc.lsp and vba file are stored in one of autocads support folders, preferrably the first folder in the list.
Before you get too far into vba, you might want to look at vb .net, or c#.net as vba in autocad is on it's way out.
As far as I know, 2011 is the last version to support vba.
Put the following in the Macro definition of a toolbar button:
^C^C_.-vbarun;"C:/MyPath/MyMacroFilename.dvb!MyModuleName.MyRoutineName";
This is also what I use, however I just came across a few toolbar buttons that weren't working when I changed to a newer directory. I was confused and frusterated for a while. The last thing I tried was to shorten the lengths of the sub procedure names, and it worked!
I have a feeling there is some path length limitation for the path in quotes below, however I could be wrong I'm only guessing. The path length of 111 characters worked for me, but the length of 133 characters didn't.
^C^C_.-vbarun;"C:/MyPath/MyMacroFilename.dvb!MyModuleName.MyRoutineName";
The -vbarun; etc. line is how to do it. You should know that it is possible to pass arguments in that very same line to your VBA. Thus you can have that VBA act upon the arguments passed to it. So keep that in mind as a way to leverage your VBA functionality.