How can I load a VBA project automatically when AutoCAD is launched

How can I load a VBA project automatically when AutoCAD is launched

Anonymous
Not applicable
821 Views
6 Replies
Message 1 of 7

How can I load a VBA project automatically when AutoCAD is launched

Anonymous
Not applicable
I need to automatically load and run a VBA project when AutoCAD is launched. The following method did not work:
----
Any project other than the default, acad.dvb, can be used by explicitly loading that project at startup using the VBALOAD command. The following code sample uses the AutoLISP startup file to load VBA and a VBA project named myproj.dvb when AutoCAD is started. Start notepad.exe and create (or append to) acad.lsp the following lines:
(defun S::STARTUP()
(command "_VBALOAD" "myproj.dvb")
)
----

I don't have acad.lsp file. I created this file and save it under 'C:\Program Files\AutoCAD2004' folder. But when I started the AutoCAD it did not load the VBA project! Could someone help please?
0 Likes
822 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
1. Create a text file named ACAD.RX in your support directory and place
one line in it - acadvba.arx with/without the path to it
2. Place acad.dvb in your support directory and in it create a sub
called ACADStartup()

For more info, read the help file!

___________________________
Mike Tuersley
AutoCAD Clinic
Rand IMAGINiT Technologies
0 Likes
Message 3 of 7

Anonymous
Not applicable
Have you looked into the startup
suite?

 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I
need to automatically load and run a VBA project when AutoCAD is launched. The
following method did not work:
----
Any project other than the
default, acad.dvb, can be used by explicitly loading that project at startup
using the VBALOAD command. The following code sample uses the AutoLISP startup
file to load VBA and a VBA project named myproj.dvb when AutoCAD is started.
Start notepad.exe and create (or append to) acad.lsp the following lines:

(defun S::STARTUP()
(command "_VBALOAD" "myproj.dvb")
)
----

I don't have acad.lsp file. I created this file and save it under
'C:\Program Files\AutoCAD2004' folder. But when I started the AutoCAD it did
not load the VBA project! Could someone help
please?

0 Likes
Message 4 of 7

Anonymous
Not applicable
Thanks Mike, But will you explain for me a little more. I have a project that is saved on "C:\Projects\RK\RKCADInt\RKCADInt.dvb". This project is nothing but just a simple VBA form that I a select some dwg files and then I am trying to open all of the in one dwg file.

1) I created ACAD.RX in support folder.
2) I added the following line:
acadvba.arx
I don't have any file with name acadvba.arx. But I did the same as you have mentioned.
I copied "RKCADInt.dvb" into support folder.
After launcing the ACAD, I get the following message in command line level of the CAD, which indicate it can not load the project:

Regenerating model.
acrxGetApiVersion not found in C:\Projects\RK\RKCADInt\RKCADInt.dvb
Make sure the app links with rxapi.lib and export the symbol.AcRxDynamicLinker
failed to load 'C:\Projects\RK\RKCADInt\RKCADInt.dvb'
C:\Program Files\AutoCAD2004\acad.exe

Does loading a project is equivalent by making the form visible? Where I am going wrong? Many Thanks, Amir
0 Likes
Message 5 of 7

Anonymous
Not applicable
In regards to your original post, your startup line
would probably work if you included the full path to your project. Note that
vbaload only loads the dvb, you still have to run a macro.

 

In regards to Mike's suggestion, I think you need
to modify that to work with 2004. To be more consistent with other file naming
conventions, the file was renamed to: acvba.arx.


--
--
Ed
--


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Thanks
Mike, But will you explain for me a little more. I have a project that is
saved on "C:\Projects\RK\RKCADInt\RKCADInt.dvb". This project is nothing but
just a simple VBA form that I a select some dwg files and then I am trying to
open all of the in one dwg file.

1) I created ACAD.RX in support folder.
2) I added the following line:

acadvba.arx
I don't have any file with name acadvba.arx. But I did the
same as you have mentioned.
I copied "RKCADInt.dvb" into support folder.

After launcing the ACAD, I get the following message in command line level
of the CAD, which indicate it can not load the project:

Regenerating model.
acrxGetApiVersion not found in
C:\Projects\RK\RKCADInt\RKCADInt.dvb
Make sure the app links with
rxapi.lib and export the symbol.AcRxDynamicLinker
failed to load
'C:\Projects\RK\RKCADInt\RKCADInt.dvb'
C:\Program
Files\AutoCAD2004\acad.exe

Does loading a project is equivalent by making the form visible? Where I am
going wrong? Many Thanks, Amir

0 Likes
Message 6 of 7

Anonymous
Not applicable
What I do is create a Lisp file and use the vl-vbarun command to load and launch the vba routine. This is also allows you to define commands that can be run from the command line without typing the vbarun syntax and makes menu customization much simpler.
0 Likes
Message 7 of 7

Anonymous
Not applicable
Thanks Ed, I forgot to mention that 2004 renamed the file to acadvba.arx
___________________________
Mike Tuersley
AutoCAD Clinic
Rand IMAGINiT Technologies
0 Likes