Can an add-in run code automatically when loaded?

burma

Member
Local time
Today, 13:31
Joined
Jan 17, 2024
Messages
61
I have an Access file that does one thing when it opens: it displays the message "hello". I then install the file as an add-in. When I open another Access file, let's call it Add-in Test A.accdb, the add-in is there in the Add-ins menu but the "hello" message doesn't display unless I click it from the Add-ins menu. Is there a way to make it so the Add-in will display the message automatically when I open any Access file, not just Add-in Test A.accdb? Thx
 
Can you add an autoexec macro in the new db and call the code in the add in?
 
Can you add an autoexec macro in the new db and call the code in the add in?
Tried that but no dice: the msgbox doesn't fire unless I click the add-in from the Add-ins menu.
 
the add-in is there in the Add-ins menu but the "hello" message doesn't display unless I click it from the Add-ins menu
If this is an Access add-in, it is only loaded when you start it from the add-in menu or via another call.
Only the presence in the add-in menu cannot start a code.
 
I may be wrong but I think Access add-ins cannot start automatically. They do have to be loaded each time you need them.
If you only use the add-in to run code, then an alternative is to add the file as a library reference and that will be loaded automatically at startup. However, doing that won't allow you to open forms from the add-in file.
 
I may be wrong but I think Access add-ins cannot start automatically. They do have to be loaded each time you need them.
If you only use the add-in to run code, then an alternative is to add the file as a library reference and that will be loaded automatically at startup. However, doing that won't allow you to open forms from the add-in file.
So are you talking about a COM add-in? Perhaps having two add-ins: a COM add-in and an Access add-in. But the goal is to start automatically, and run code. Maybe I would want to open forms in a later version. The other goal is Ribbons that would only show when the add-in is started.
 
I was referring to 'standard' Access add-ins.
COM add-ins are totally different and can start automatically but I have no experience of creating those.
 
If you are using a COM add-in, IDTExtensibility2 and IRibbonExtensibility are available as interfaces.


The other goal is Ribbons that would only show when the add-in is started.
This should also be possible with an Access add-in.
You write above that the add-in should be loaded automatically. - This is not possible with an Access add-in.

How should the add-in be started?
  • Per user activity (click on button in the application, application ribbon or in the add-in menu, ...)
  • When a specific application/database is loaded
  • When any database file is loaded
  • When Access is started
If I understood #1 correctly, it should be one of the last 2 points. => COM-Add-In
 
Last edited:
You write above that the add-in should be loaded automatically. - This is not possible with an Access add-in.
Can an Access add-in be loaded from a COM add-in?

How should the add-in be started?
  • Per user activity (click on button in the application, application ribbon or in the add-in menu, ...)
  • When a specific application/database is loaded
  • When any database file is loaded
  • When Access is started
If I understood #1 correctly, it should be one of the last 2 points. => COM-Add-In
Yes, the last two. Or at least: when any database file is loaded. Thx
 
Last edited:
Can an Access add-in be loaded from a COM add-in?
Yes, if an Access.Application object is available.
AccessApplicationReference.Run "PathToAddinAccdaWithoutFileExt.AddInFunktion"
 
Yes, if an Access.Application object is available.
AccessApplicationReference.Run "PathToAddinAccdaWithoutFileExt.AddInFunktion"
So, assuming the Access.Application object is available, I can kick off the the Access add-in from COM. The only thing I would need the COM add-in for is to load the Access add-in. The rest of the code would run from the Access add-in presumably. Sound doable?
 
Just for info: You can create a COM add-in quite easy with twinBASIC (compared to .NET or other solutions):
 
A simple example:
This COM add-in does nothing other than provide a ribbon to start various access add-ins from the ribbon.
The add-in was created with twinBasic, but it is not much different with C# either.
 
Just for info: You can create a COM add-in quite easy with twinBASIC (compared to .NET or other solutions):
Thanks - I've read about twinBASIC. is there a free version?
 
Yes. Both, 32-bit and 64-bit versions are free. But 64-bit shows a 5 second nag screen.
 
A simple example:
This COM add-in does nothing other than provide a ribbon to start various access add-ins from the ribbon.
The add-in was created with twinBasic, but it is not much different with C# either.
Except, I need a COM add-in to actually load the Access add-in, not just provide a ribbon. Thx
 

Users who are viewing this thread

Back
Top Bottom