R2005 VBA Hello all! I'm beginning to use the built in VBA in AutoCAD. I had followed a tutorial and created a project. After I opened AutoCAD, I typed in VBAIDE and the visual basic console opened. Then at the command prompt, I typed in (vl-vbaload "g:/vba/BZProjectTest.dvb") and my project loaded into the VBA console and was now visible in the console. Next I typed in (vl-vbarun "g:/vba/BZProjectTest.dvb!testmacro") and my dialog became visible on the AutoCAD screen and everything worked as expected. But when I look at the VBA console, I now show two BZProject1(g:\vba\bzprojecttest.dvb) in the project window. What am I doing wrong? And what do Ido to get rid of one of the sessions of BZProject1(g:\vba\bzprojecttest.dvb)? This happended yeaterday too when I did a vbaload 2 times in a row. Any help would be appreciated. TIA Bill
Hi Bill, You must mean you typed in VLIDE and the visual lisp console opened... I've been using the following lisp to -load and- run my vba macros. (vla-RunMacro (vlax-get (vlax-get-Acad-Object) 'ActiveDocument) "<projectname>.dvb!<modulename>.<macroname>") If I remember right, vl-vbarun will -load and- run your macro, but I didn't think it would load it again if it was already loaded. <not much farther along myself> To get rid of one, use VBAMAN and unload one. -- James Allen, EIT Malicoat-Winslow Engineers, P.C. Columbia, MO opened. Then at the command prompt, I typed in (vl-vbaload "g:/vba/BZProjectTest.dvb") and my project loaded into the VBA console and was now visible in the console. dialog became visible on the AutoCAD screen and everything worked as expected. But when I look at the VBA console, I now show two BZProject1(g:\vba\bzprojecttest.dvb) in the project window. of BZProject1(g:\vba\bzprojecttest.dvb)?
I tried this syntax and it seems to work. (vl-vbarun "G:/WARE/vb/HatchUpdate.dvb!Fix_Hatch") (example) 'FIX HATCH DISPLAYPROBLEMS WITH GRAVEL & CONCRETE (defun c:FixHatch () (vl-vbarun "G:/WARE/vb/HatchUpdate.dvb!Fix_Hatch") )
You must mean you typed in VLIDE and the visual lisp console opened... Why? He said he was using VBA. Did I miss something?
Oops! <"BillZ" wrote ... at the command prompt ...> I missed that part. Went straight from the visual basic console to typing in lisp code and it didn't make much sense. So I interpreted that he was trying out his vba-loading lisp code on the fly in vlide. But he was trying it right at the command prompt, just like he said. Sorry Bill. Thanks Paul. James
Bill, it looks like both vl-vbaload and vl-vbarun can load the same project that is already loaded. I haven't *noticed* such issues with the variation I posted earlier, but haven't checked for them either. You probably already know this, but if your code shows up when you use vbaide, then it is already loaded in the AutoCAD session. For working code, I think its probably best to always let one of the runmacro functions -load and- run your macros.
Hi JAmes, No I actually meant: "I typed in VBAIDE and the visual basic console opened." But anyway, thanks for the tip,I never thought about VBAMAN. Bill
Bill, it looks like both vl-vbaload and vl-vbarun can load the same project that is already loaded. I haven't *noticed* such issues with the variation I posted earlier, but haven't checked for them either. You probably already know this, but if your code shows up when you use vbaide, then it is already loaded in the AutoCAD session. For working code, I think its probably best to always let one of the runmacro functions -load and- run your macros. <<< It's kinda weird, I did the same thing this morning (just testing). The one I loaded using: (vl-vbaload "g:/vba/BZProjectTest.dvb") Showed up as: BZProject1 (g:\vba\BZProjectTest.dvb) and the one that loaded when I used. (vl-vbarun "g:/vba/BZProjectTest.dvb!testmacro") Showed up as: BZProject1 (G:\vba\BZProjectTest.dvb) Guess i'll just stay away from the vbaload function. Thanks Bill
(example) 'FIX HATCH DISPLAYPROBLEMS WITH GRAVEL & CONCRETE (defun c:FixHatch () (vl-vbarun "G:/WARE/vb/HatchUpdate.dvb!Fix_Hatch") )<<< Ah, The lights keep coming on... Thanks Bill