PDA

View Full Version : Automatically Load and Start a VBA project.



MZerby
2005-01-10, 05:43 PM
We have a standard template drawing that I'm trying to load a .dvb into and run a macro in on startup. I then unload the .dvb. My problem is that I put the LoadDVB in the AcadDocument_Activate() event of ThisDrawing, so every time the drawing is activated after the first time, I get an error because it can not run. How can I Load and run the .dvb when I open the template and not have it try to run after that?

ntaylor
2005-01-10, 10:41 PM
Can you embed a VBA project in the template and in this project have the following procedure:


Option Explicit

Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
If CommandName = "NEW" Then
MsgBox "Hello"
End If
End Sub

Regards - Nathan

Ed Jobe
2005-01-10, 11:46 PM
This sounds like the kind of thing where you might be trying to do something and there might be better ways to do it. Rather than us giving you a direct answer, perhaps you could tell us your goal and we could advise you on how to get there. For example, have you tried acad.dvb and an ACADStartup procedure?

RobertB
2005-01-11, 03:22 AM
... For example, have you tried acad.dvb and an ACADStartup procedure?
Exactly! ;)

MZerby
2005-01-11, 10:22 PM
There probably are better ways to do what I'm trying. I've been trying to learn on my own from examples. What I'm trying to do is open a cover sheet from a template and run a macro that lets you pick options from a dialog box. Then it strips out all the objects that are not needed. I embedded a macro in the template under the activate event, that searches for a layer that is in the template. If it's there it loads a .dvb and runs it. When it runs it removes the layer that it searches for so it will not load and run the .dvb again, I then unload the .dvb.

It seems to load and run fine if I run it from my computer, but if I try to run it from another computer on the network it fails when it tries to activate VBA. They have rights to the directory the .dvb is in. If I embed the .dvb in the drawing it works fine. Does anyone have any idea what my problem may be or maybe a better solution?

RobertB
2005-01-13, 04:24 PM
It seems to load and run fine if I run it from my computer, but if I try to run it from another computer on the network it fails when it tries to activate VBA. They have rights to the directory the .dvb is in. If I embed the .dvb in the drawing it works fine. Does anyone have any idea what my problem may be or maybe a better solution?
Have you added the line:
acvba.arx

to the Acad.rx file?

This is discussed in the help file's under the topic "Automatically Load and Execute VBA Projects"

MZerby
2005-01-13, 11:30 PM
Have you added the line:
acvba.arx

to the Acad.rx file?

This is discussed in the help file's under the topic "Automatically Load and Execute VBA Projects"
Thank You very Much!

The template seems to open and run fine now.

RobertB
2005-01-14, 06:40 AM
Glad I could help.

pangus
2005-01-27, 11:50 PM
Thank you for the information shared here. I have found it most useful.