Can an add-in run code automatically when loaded? (1 Viewer)

burma

Member
Local time
Yesterday, 22:51
Joined
Jan 17, 2024
Messages
50
Yes. Both, 32-bit and 64-bit versions are free. But 64-bit shows a 5 second nag screen.
I assume I need 32 bit version. I'm on Win10 64 bit but running Access 32 bit.
 

AHeyne

Registered User.
Local time
Today, 07:51
Joined
Jan 27, 2006
Messages
92
Yes, but only for 32 bit.
This is a commercial project, though the 32-bit Windows version of the project will be available completely free of charge. Developers that need to build 64-bit binaries will either need to purchase a licence or endure a 5-second twinBASIC splash screen when their applications start.
So 'practically' 64-bit it is free too...
 

Josef P.

Well-known member
Local time
Today, 07:51
Joined
Feb 2, 2023
Messages
826
Except, I need a COM add-in to actually load the Access add-in, not just provide a ribbon.
The call is the same, it just takes place in a different place. ;)

It could be somewhat difficult that the call should only be made when the accdb file is loaded, as the COM add-in is already loaded with Access.
=> presumably, as long as no Access.Application object is available, you must frequently check in the COM add-in when an accdb has been loaded.
 

burma

Member
Local time
Yesterday, 22:51
Joined
Jan 17, 2024
Messages
50
The call is the same, it just takes place in a different place. ;)

It could be somewhat difficult that the call should only be made when the accdb file is loaded, as the COM add-in is already loaded with Access.
=> presumably, as long as no Access.Application object is available, you must frequently check in the COM add-in when an accdb has been loaded.
Couldn't the COM add-in be unloaded completely once the Access add-in is loaded?
 

Josef P.

Well-known member
Local time
Today, 07:51
Joined
Feb 2, 2023
Messages
826
Couldn't the COM add-in be unloaded completely once the Access add-in is loaded?
Should be possible.
Short test:
Code:
Private Sub TestUnLoadComAddIn()

    Dim ca As COMAddIn

    For Each ca In Application.COMAddIns
        If ca.ProgId = "AClibAddInStarter.AddIn" Then
            ca.Connect = False
        End If
        Debug.Print ca.Connect, ca.Description, ca.ProgId, ca.guid
    Next

End Sub
Works
/edit:
.. Is unloaded, but no longer load automatically. => You will then probably have to regulate the next start via the registry.

But: why should the add-in be unloaded, should it no longer call up the Access add-in when you change the accdb file in the Access application?
 
Last edited:

burma

Member
Local time
Yesterday, 22:51
Joined
Jan 17, 2024
Messages
50
Should be possible.
Short test:
Code:
Private Sub TestUnLoadComAddIn()
  
    Dim ca As COMAddIn
  
    For Each ca In Application.COMAddIns
        If ca.ProgId = "AClibAddInStarter.AddIn" Then
            ca.Connect = False
        End If
        Debug.Print ca.Connect, ca.Description, ca.ProgId, ca.guid
    Next

End Sub
Works. :)
(y) So I just need to put the pieces to put together. Do you have a project file you could provide? I'm using VStudio but I might try twinBASIC and some of the samples listed. Thx
 

burma

Member
Local time
Yesterday, 22:51
Joined
Jan 17, 2024
Messages
50
Should be possible.
Short test:
Code:
Private Sub TestUnLoadComAddIn()

    Dim ca As COMAddIn

    For Each ca In Application.COMAddIns
        If ca.ProgId = "AClibAddInStarter.AddIn" Then
            ca.Connect = False
        End If
        Debug.Print ca.Connect, ca.Description, ca.ProgId, ca.guid
    Next

End Sub
Works
/edit:
.. Is unloaded, but no longer load automatically. => You will then probably have to regulate the next start via the registry.

But: why should the add-in be unloaded, should it no longer call up the Access add-in when you change the accdb file in the Access application?
I don't know that I need to unload it, and I certainly wouldn't want to unregister it once it's working. I'd just be using it as a launcher for the Access add-in. Any time an Access file is opened, it would load the Access add-in and then be no longer needed until I open an Access file again.
 

Josef P.

Well-known member
Local time
Today, 07:51
Joined
Feb 2, 2023
Messages
826
Do you have a project file you could provide?
twinBasic example see #16.
C# example for Extensibility.IDTExtensibility2: https://source.access-codelib.net/f...ith_SimplyVBUnit/src/AccUnit.AddIn/connect.cs

Any time an Access file is opened, it would load the Access add-in and then be no longer needed until I open an Access file again.
Remember: you can also load a new file without closing Access. If the add-in is to react again, it must be running in my opinion.
 

burma

Member
Local time
Yesterday, 22:51
Joined
Jan 17, 2024
Messages
50
twinBasic example see #16.
C# example for Extensibility.IDTExtensibility2: https://source.access-codelib.net/filedetails.php?repname=AccUnit&path=/tags/AccUnit_with_SimplyVBUnit/src/AccUnit.AddIn/connect.cs


Remember: you can also load a new file without closing Access. If the add-in is to react again, it must be running in my opinion.
Since I only need the COM add-in to load my Access add-in, I'm wondering what the effect will be if I then unload the COM add-in? I guess I'll find out once I put something together. Thanks
 

Josef P.

Well-known member
Local time
Today, 07:51
Joined
Feb 2, 2023
Messages
826
... what the effect will be if I then unload the COM add-in?
This has no effect on the Access add-in.

Interesting question: what kind of access add-in is this that is supposed to execute something when opening each accdb/accde?
If it is supposed to run on every accdb, I would expect an add-in for developers, as I would rather build something like this into the application for end users.
 

burma

Member
Local time
Yesterday, 22:51
Joined
Jan 17, 2024
Messages
50
Interesting question: what kind of access add-in is this that is supposed to execute something when opening each accdb/accde?
If it is supposed to run on every accdb, I would expect an add-in for developers, as I would rather build something like this into the application for end users.
It's for dev and testing purposes but could be useful for end users also.
 

duster34a

New member
Local time
Today, 11:21
Joined
Jan 31, 2024
Messages
1
I'm basically going crazy here. I've wrote short Python scripts at work to open spreadsheets and launch specific macros in those spreadsheets. Everything works, except that we use custom Excel add-ins that we wrote (custom functions). When I open the workbook manually, the add-in activates automatically and the file refreshes correctly. However, opening from Python seems to deactivate all the add-ins and therefore the file doesn't refresh correctly (my custom functions give errors).
 

burma

Member
Local time
Yesterday, 22:51
Joined
Jan 17, 2024
Messages
50
I'm basically going crazy here. I've wrote short Python scripts at work to open spreadsheets and launch specific macros in those spreadsheets. Everything works, except that we use custom Excel add-ins that we wrote (custom functions). When I open the workbook manually, the add-in activates automatically and the file refreshes correctly. However, opening from Python seems to deactivate all the add-ins and therefore the file doesn't refresh correctly (my custom functions give errors).
Same issue I had: an office add-in isn't active and loaded until you manually load it (by clicking it in the add-in tab). I wish there were a way to load it automatically but it seems like that would require a COM wrapper.
 

Users who are viewing this thread

Top Bottom