Hi Perry,
As you would expect there is a collection of loaded programs which can be
investigated, but there is no point in going to all that trouble.
The VBARUN command and it's variants will load (if necessary) and run the
program. The best way to run your VBA macros, is to define lisp functions
to run them. Put the lisp programs in your custom menu file, say PERRY.MNL
. These functions get loaded when you load the PERRY.MNU, or PERRY.MNS, or
PERRY.MNC file as the case may be.
A typical example is:
(setq sLandToolboxPath
(strcat
(vl-registry-read
"HKEY_LOCAL_MACHINE\\Software\\CADApps\\LandToolbox" "VBA Program Path")
"\\"
)
)
In this case the program is installed by "Inno Setup" which writes the
installation path to the registry. The code above reads the registry and
gets the path. You could easily simply hard code a path here.
The code below adds the file and macro name to the path and then uses
vl-vbarun to run the function. vl-vbarun runs the macro, loading it if
necessary.
(defun C:CA_DuplicatePointsAbout ()
(setq sLandToolboxFunction (strcat sLandToolboxPath
"CADApps_DuplicatePointsL3.dvb!DuplicatePointsAbout"))
(vl-vbarun sLandToolboxFunction)
(CADApps_BlankCommandLine sLandToolboxFunction)
)
The code below tidies up the command line when you run the macro
(defun CADApps_BlankCommandLine (spString)
(setq n (strlen spString))
(repeat n(prompt(chr 8)))
(repeat n(prompt(chr 32)))
(princ)
)
The MNU (or MNS) file contains
CA_DupPts [ About Duplicate Points]^C^C^CCA_DuplicatePointsAbout;
Advantages of this process are that you can:
press
to repeat the menu command.
type the "CA_DuplicatePointsAbout " command at the keyboard.
the macro is only loaded if used.
the lisp is only loaded if you load the menu.
by having the path in the registry it's easy to maintain the system if you
wish to make changes to the program location with an installation program..
--
Laurie Comerford
CADApps
www.cadapps.com.au
"perry" wrote in message news:401e9fc7$1_1@newsprd01...
> I want to load some VBA routines each time a drawing is opened (without
> using an "acad.dvb" file).
> I know I can do this in an "acaddoc.lsp" file with a few lines that look
> something like this:
>
> (if (findfile "perry.dvb")
> (command "_-vbaload" "perry")
> (alert "personal VBA not loaded.")
> )
>
> The problem with this approach is that upon opening subsequent drawings I
> get an alert box stating that the vba module is already loaded.
> With autolisp files I can use a line like this:
> (defun C:LM () (if (not c:lman)(load "lman"))(c:lman))
> which will fist check if the routine is already loaded, then load and
> execute if it is not. So my question is can I do something similiar with
> VBA?
> Something along the line of:
> (if (not VBAPROJECTNAME)(vbaload "VBAPROJECTNAME"))(macroname))
>
> Thanks
> --
> Perry Leets
> Inovec Optimization and Control Systems
> Eugene, Oregon
>
>