I don't think you can. There is, however, something that you can do to make
your Access apps automation-friendly. Your start-up code can test the
Application.UserControl property, and execute its usual startup code only if
the property returns True.
For example, create an MDB with an AutoExec macro that uses the RunCode
action to call the following function ...
Public Function StartupFunction()
If Application.UserControl Then
MsgBox "Hi there, user!"
End If
End Function
When you open this MDB normally, without using automation, you'll see the
message box. Now open the same MDB via automation ...
Option Compare Database
Option Explicit
Private mobjApp As Access.Application
Public Sub TestAuto()
Set mobjApp = New Access.Application
mobjApp.OpenCurrentDatabase ("c:\usenet\autotarget.mdb")
mobjApp.Visible = True
End Sub
Notice that the message box is not shown.
--
Brendan Reynolds
Access MVP
Post by JonathanHi, I want to use vba to open another database. When I do, the autoexec in
the other database is triggered.
How can I open this other database without running the autoexec in the other
database?
Any ideas or suggestions appreciated :-)
Many thanks
Jonathan