VBA equivalent to S::Startup

VBA equivalent to S::Startup

Anonymous
Not applicable
397 Views
6 Replies
Message 1 of 7

VBA equivalent to S::Startup

Anonymous
Not applicable
Hello;

I'm trying to get a VBA program to work which is designed to apply various
settings to new and existing drawings automatically when they have opened.
The thing that I'm looking for is the VBA equivalent to the Lisp function
S::Startup. I have thought of the AcadApplication objects declared with the
WithEvents statement but the problem is twofold: the events are not
triggered for the initial new drawing when starting Acad from a shortcut and
the AcadApplication does not have an equivalent to the EndOpen event for a
new drawing.

Can someone tell me if there is a way to do what I want without resorting to
something like:
(defun-q S::Startup () (command "-vbarun MyFunc")) put into the Acad.lsp
file?

Sincerely;
Michelle
0 Likes
398 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
Hi Michelle

A file named Acad.dvb in the Acad search path loads automatically. I don't
recall the name, but I believe that a sub identified by that name will also
run automatically.

I use the vlisp stuff and haven't had any problems:

I demand load with:

(defun C:runvba ()
(vl-vbaload "C:\\MyFolder\\MyVBA.dvb")
(vl-vbarun "MyMacro")
);end function

Since the vl- ... does not use the "command" function you don't need the
S::Startup. You can remove the "defun" and put the load in one of your lisp
startup files.

There is some good info and cautions at the link below:

http://pointa03.autodesk.com/kdn/content/solutions/58357.htm

Hope this helps,

Gary
0 Likes
Message 3 of 7

Anonymous
Not applicable
I've tried the AcadStartup macro method below. I ended up using small,
embedded "bootstrap" macro in prototype drawings instead. But then I don't
have to work with any existing drawings.

--------------------------------------
ActiveX and VBA Developers Guide
Ch. 11 - Developing Applications with VBA
Automatically Running a VBA Macro

To automatically run a VBA macro at AutoCAD startup

You can automatically run any macro in the acad.dvb file by
calling it with the command line version of VBARUN from an
AutoCAD startup facility like acad.lsp. For example, to
automatically run the macro named drawline, first save the
drawline macro in the acad.dvb file. Next, invoke notepad.exe
and create (or append to) acad.lsp the following lines:

(defun S::STARTUP() (command "_-vbarun" "drawline"))

To automatically run a VBA macro when VBA loads

You can automatically run a macro in the acad.dvb file by
naming the macro AcadStartup. Any macro in your acad.dvb file
called AcadStartup will automatically get executed when VBA loads.
--
John Goodfellow
irtf'nm
use 'microtouch' in address to email

"chell" wrote in message
news:[email protected]...
> Hello;
>
> I'm trying to get a VBA program to work which is designed to apply various
> settings to new and existing drawings automatically when they have opened.
> The thing that I'm looking for is the VBA equivalent to the Lisp function
> S::Startup. I have thought of the AcadApplication objects declared with
the
> WithEvents statement but the problem is twofold: the events are not
> triggered for the initial new drawing when starting Acad from a shortcut
and
> the AcadApplication does not have an equivalent to the EndOpen event for a
> new drawing.
>
> Can someone tell me if there is a way to do what I want without resorting
to
> something like:
> (defun-q S::Startup () (command "-vbarun MyFunc")) put into the Acad.lsp
> file?
>
> Sincerely;
> Michelle
>
0 Likes
Message 4 of 7

Anonymous
Not applicable
"AcadStartup", I'll have to remember it this time.

Thanks John

>>Any macro in your acad.dvb file
>>called AcadStartup will automatically get executed when VBA loads.

Gary
0 Likes
Message 5 of 7

Anonymous
Not applicable
Just to add a little, I found I had to add a line to acad.rx ~ acadvba.arx
~ in order to get acad.dvb to run consistently.

--
Kent Keller

Check out the Mechanical Desktop FAQ @
http://mymcad.com/
"Gary McMaster" wrote in message
news:[email protected]...
> Hi Michelle
>
> A file named Acad.dvb in the Acad search path loads automatically. I don't
> recall the name, but I believe that a sub identified by that name will also
> run automatically.
>
> I use the vlisp stuff and haven't had any problems:
>
> I demand load with:
>
> (defun C:runvba ()
> (vl-vbaload "C:\\MyFolder\\MyVBA.dvb")
> (vl-vbarun "MyMacro")
> );end function
>
> Since the vl- ... does not use the "command" function you don't need the
> S::Startup. You can remove the "defun" and put the load in one of your lisp
> startup files.
>
> There is some good info and cautions at the link below:
>
> http://pointa03.autodesk.com/kdn/content/solutions/58357.htm
>
> Hope this helps,
>
> Gary
>
0 Likes
Message 6 of 7

Anonymous
Not applicable
Yo can also place the Acad.dvb file with its associated AcadStartup macro into
the "Startup suite" within AutoCAD. To access the Startup Suite, type APPLOAD
at the command prompt. Click the Startup Suite icon and add the acad.dvb file.

Mark Sanchez
SPEC Services, Inc.
Fountain Valley, CA USA

chell wrote:

> Hello;
>
> I'm trying to get a VBA program to work which is designed to apply various
> settings to new and existing drawings automatically when they have opened.
> The thing that I'm looking for is the VBA equivalent to the Lisp function
> S::Startup. I have thought of the AcadApplication objects declared with the
> WithEvents statement but the problem is twofold: the events are not
> triggered for the initial new drawing when starting Acad from a shortcut and
> the AcadApplication does not have an equivalent to the EndOpen event for a
> new drawing.
>
> Can someone tell me if there is a way to do what I want without resorting to
> something like:
> (defun-q S::Startup () (command "-vbarun MyFunc")) put into the Acad.lsp
> file?
>
> Sincerely;
> Michelle
0 Likes
Message 7 of 7

Anonymous
Not applicable
All of the other replies are valid for starting the vba app. I'll add to
them by stating that you do not need a S::STARTUP. Simply add the call to an
MNL file [assuming R14+] - it'll automatically execute AND you don't run the
risk of screwing up any existing S::STARTUP calls.

- Mike
0 Likes