Running code when drawing opens

Running code when drawing opens

Anonymous
Not applicable
247 Views
3 Replies
Message 1 of 4

Running code when drawing opens

Anonymous
Not applicable
Is there a way to make a VBA routine execute when a drawing is created (from
a template) or opened? I need to use it to check some variables when the
drawing is opened or created and inform the user of the status of those
variables before the user is able to do any work in the drawing.

Thanks in advance.

Joe Melton
PDC, Inc. Consulting Engineers
Anchorage, Alaska
0 Likes
248 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Joe,

The easiest way is by using a autolisp startup routine that calls the vba
using (vl-vbarun "yourFunction"). You could also place a line like this in
the menu.mnl which should load with each dwg unless otherwise specified. You
could also use the s:startup in autolisp.

HTH

Chris
"Joe Melton" wrote in message
news:B2317FC2B4F14412D688DF4EEF56C132@in.WebX.maYIadrTaRb...
> Is there a way to make a VBA routine execute when a drawing is created
(from
> a template) or opened? I need to use it to check some variables when the
> drawing is opened or created and inform the user of the status of those
> variables before the user is able to do any work in the drawing.
>
> Thanks in advance.
>
> Joe Melton
> PDC, Inc. Consulting Engineers
> Anchorage, Alaska
>
>
0 Likes
Message 3 of 4

Anonymous
Not applicable
put your code in the standard drawing open event.
0 Likes
Message 4 of 4

Anonymous
Not applicable
Assuming you have a LISP or MNL that is loading a standard VBA file that you
load all the time...

Then you can follow either Chris or enrich's method, either way will work.

I have a standard VBA file (DVB) that is always loaded and I put some setup
code in /Autocad Objects/ThisDrawing AcadDocument_Activate.

However! With both these methods, be certain what you are trying to do.
Because with either, you will be checking/changing settings everytime a
drawing is created or opened, NOT just created. So, if there are settings
that get changed after a drawing has been created, then they will be reset
each and everytime a drawing has been opened also.

Such as: if you create a default setup for DIMSCALE of 48, but one drawing
needs to be 96, then the next time you open the drawing, your routine will
automatically set it back to 48.

HTH.

"Joe Melton" wrote in message
news:B2317FC2B4F14412D688DF4EEF56C132@in.WebX.maYIadrTaRb...
> Is there a way to make a VBA routine execute when a drawing is created
(from
> a template) or opened? I need to use it to check some variables when the
> drawing is opened or created and inform the user of the status of those
> variables before the user is able to do any work in the drawing.
>
> Thanks in advance.
>
> Joe Melton
> PDC, Inc. Consulting Engineers
> Anchorage, Alaska
>
>
0 Likes