PDA

View Full Version : Autocad VBA Macro Button toolbar-how?



firavolla
23rd Jun 2010, 02:16 pm
Ok, I have a dvb project called SectGrinda.dvb inside a subfolder VBA_Macro of Autocad main dir.
I created the toolbar, the button, but I can't understand what i need to write inside the macro property of the button.
Now i have something like
^C^C_vbarun SectGrinda.dvb!Module1.Main

And with this, I first get the Macro dialogue of autocad, and then i have to hit run for my macro to execute. How solve it?

dbroada
23rd Jun 2010, 02:23 pm
I'm just guessing here as I'm not at work, have you tried a ; after the .Main to force an enter?

metal_pro
23rd Jun 2010, 06:23 pm
Been there - done that!

Try changing _vbarun to -vbarun in your button macro

^C^C-vbarun SectGrinda.dvb!Module1.Main
this should run the function Main in module1

^C^C_vbarun SectGrinda.dvb!Module1.Main
this will show the Macros dialog box and expect you to then hit run

I think your best to load the file in your acad lisp startup then use your button to run the macro

look in the ACAD HELP

Run a VBA Macro from a Toolbar or Menu-VBARUN filename.dvb!modulename.macroname


Automatically Load a VBA ProjectAutomatically Load a VBA Project (defun S::STARTUP()
(command "_VBALOAD" "myproj.dvb")
)
Automatically Run a VBA MacroAutomatically Run a VBA Macro(defun S::STARTUP() (command "_-vbarun" "drawline"))

firavolla
24th Jun 2010, 07:24 am
I had already looked in Acad help...But it doesn't seem to work. Using the - i get a Macro not found when clicking the button. Also, the macro is loaded at Acad startup using the load application option in the menu....Anymore ideas?

firavolla
24th Jun 2010, 10:25 am
Thank you guys for your help. It was actually because In the folder I had the project file, i also had a subfolder and in there a backup of the project but with the same name. It should have worked even so, but for some reason it didn't. I renamed that backup and now it works great!