VBA: Disable all addins except one predefined addin

excelstarter1

Board Regular
Joined
Jul 20, 2017
Messages
81
Hey guys,

I tried the following code to deactivate all running addins except one addin which I want to keep. However, I always get runtime error "Subscript out of range (Error 9)" in the Installed = False line of my code. I was not able to deactive any addins so far... Do you have a better approach or an improvement of my code?

Thanks in advance!
Regards

Code:
Sub DeactivateAddIns()
Dim i As Integer
Dim MyaddInName As String

For i = 1 To AddIns.count
MyaddInName = AddIns(i).Name
If MyaddInName = "AddinIWantToKeep" Then 'Skip the Addin I want to keep
Else
Application.AddIns(MyaddInName).Installed = False 'Deactivate all addins
End If
Next i

End Sub
 
Last edited:

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Do you have any XLL addins ?

anyway give this a try and see if it works :
Code:
Sub DeactivateAddIns()
    Dim oAddin As AddIn
    Dim MyaddInName As String
    
    MyaddInName = "AddinIWantToKeep"
    For Each oAddin In AddIns
        If InStr(UCase(oAddin.Name), UCase(MyaddInName)) = 0 Then 
            oAddin.Installed = False
        End If
    Next
End Sub
 
Last edited:
Upvote 0
Thanks! Yes, I also have XLL and COM Addins and I want to deactive all of those running addins.

I will try your code and let you know.
 
Upvote 0
Great, it does work for my "regular" Excel-Addins.

Do you know an approach how to deactivate COM and XLL addins? Especially COM addins...

Is there a way to (1) store all active addins in a variant/variable, (2) run my macro without these addins interfering/slowing down (3) and then reactive the addins again after macro is completed?

Thanks!
 
Last edited:
Upvote 0
Great, it does work for my "regular" Excel-Addins.

Do you know an approach how to deactivate COM and XLL addins? Especially COM addins...

Is there a way to (1) store all active addins in a variant/variable, (2) run my macro without these addins interfering/slowing down (3) and then reactive the addins again after macro is completed?

Thanks!

Hi excelstarter1,

I am not quite familiar with xll or com addins so I can't advise you . hopefully someone with the knowledge who visits this thread can help.

Have you tried googling the subject ? I am sure you will find some code examples.
 
Upvote 0

Forum statistics

Threads
1,223,970
Messages
6,175,713
Members
452,667
Latest member
vanessavalentino83

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top