muck Posted October 28, 2010 Share Posted October 28, 2010 Using AutoCad 2010. I have used the following proceedure to load my VBA rounines. I run the proceedure during startup and the keyin the command when I want to use may routine. If I use the command twice the vba program loads twice. Is there a way to test a vba program to see if it is allready load then load the program only if it is not loaded. The proceedure is listed is below: (defun C:opn () (vl-vbaload "C:/PgCADvba/OpenDrawing.dvb") (vl-vbarun "opn") ) Thank you, Quote Link to comment Share on other sites More sharing options...
Grant Posted October 28, 2010 Share Posted October 28, 2010 I don't know if there is a way of doing that one but how about load your VBA then run then unload it once you have finished. (command "_vbaload" "myfile.dvb") (command "filedia" 1) (command "-vbarun" "mf") (command "_vbaunload" "myfile.dvb") Hope this helps Quote Link to comment Share on other sites More sharing options...
muck Posted November 1, 2010 Author Share Posted November 1, 2010 I am looking for a program that checks to see if a VBA program is allready loaded. If loaded, don't load it again. If it is not loaded the program needs to load it. Is there a way to do that? Thank you, Quote Link to comment Share on other sites More sharing options...
BlackBox Posted November 1, 2010 Share Posted November 1, 2010 This *may* be what you're after... Command Macro: ^C^C^P(if (not c:[color=red][i]FOO[/i][/color]) (load "[color=red][i]<FilePath>[/i][/color]\\[color=red][i]FOO[/i][/color].lsp")) c:[color=red][i]FOO[/i][/color] LISP Command: (defun c:[color=red][i]FOO[/i][/color] (/ appName) (vl-load-com) (setq appName (strcat "[color=red][i]<FilePath>[/i][/color][color=#000000]\\[color=red][i]<FileName>[/i][/color].dvb" "![color=red][i]<MacroName>[/i][/color].lrb"))[/color] (vl-vbarun appName) (princ)) Now, to unload the VBA Macro... Either include a sub-function call at the end of your macro, or use a command reactor (reference the :vlr-CommandEnded event in the Developer Documentation) to run: (vla-unloaddvb [color=red][i]<ApplicationObject>[/i][/color]) Hope this helps! Edit: Be sure to use tags. Quote Link to comment Share on other sites More sharing options...
alanjt Posted November 1, 2010 Share Posted November 1, 2010 ?? (if c:CommandName blah blah ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.