I am trying to create a new instance of Excel using VBA using:
Set XlApp = New Excel.Application
The problem is that this new instance of Excel doesn't load all the addins that load when I open Excel normally...Is there anything in the Excel Application object for loading in all the user-specified addins?
I'm not trying to load a specific add-in, but rather make the new Excel application behave as though the user opened it themself, so I'm really looking for a list of all the user-selected add-ins that usually load when opening Excel.
Then we can go to Registry Editor, try to navigate to HKEY_CURRENT_USER\Software\Microsoft\Office\Excel\Addins , find the addin and change its value of LoadBehavior to 3, it means the addin loaded at startup.
Click the File tab, click Options, and then click the Add-Ins category. In the Manage box, click COM Add-ins, and then click Go. The COM Add-Ins dialog box appears. In the Add-Ins available box, select the check box next to the add-in that you want to install, and then click OK.
Disabled Application Add-ins To solve the problem, select “Disabled Items” in the “Manage:” drop down at the bottom of the dialog and click “OK”. In the Disabled Items dialog select the add-in and click “Enable” and then close the dialog.
Make sure that you click on the workbook you want to add the reference to, and from the VBA editor menu choose Tools -> References. In the displayed list check the box beside your renamed add-in, and then click on OK. You'll see that your workbook now has a new reference to the add-in.
I looked into this problem again, and the Application.Addins collection seems to have all the addins listed in the Tools->Addins menu, with a boolean value stating whether or not an addin is installed. So what seems to work for me now is to loop through all addins and if .Installed = true then I set .Installed to False and back to True, and that seems to properly load my addins.
Function ReloadXLAddins(TheXLApp As Excel.Application) As Boolean
Dim CurrAddin As Excel.AddIn
For Each CurrAddin In TheXLApp.AddIns
If CurrAddin.Installed Then
CurrAddin.Installed = False
CurrAddin.Installed = True
End If
Next CurrAddin
End Function
Using CreateObject("Excel.Application")
would have the same result as using New Excel.Application
, unfortunately.
You will have to load the Addins that you need individually by file path & name using the Application.Addins.Add(string fileName)
method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With