Mit folgender Funktion kann man sich anzeigen lassen, welche
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Subroutine zum Anzeigen von Add-Ins in der Anwendung | |
Public Sub DisplayAddIns(Optional onlyInstalled As Boolean = False) | |
Dim AD As AddIn | |
' Durchgeht alle Add-Ins in der Anwendung | |
For Each AD In Application.AddIns | |
' Zeigt alle Add-Ins oder nur die installierten an | |
If onlyInstalled = False Then | |
Debug.Print AD.Path & AD.Name & " | " & AD.Installed | |
ElseIf onlyInstalled = True And AD.Installed = True Then | |
Debug.Print AD.Path & AD.Name | |
End If | |
Next | |
End Sub |
Mit folgender Funktion kann man ein Excel Addin aktivieren/installieren:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Funktion zum Aktivieren eines Add-Ins | |
Public Function ActivateAddIn(strAddInName As String) As Boolean | |
Dim AD As AddIn | |
Dim isInstalled As Boolean | |
isInstalled = False | |
Dim ADPath As String | |
' Durchgeht jedes Add-In in der Anwendung | |
For Each AD In Application.AddIns | |
ADPath = AD.Path & "\" & AD.Name | |
' Überprüft, ob das Add-In bereits installiert ist | |
If ((AD.Name = strAddInName) Or (ADPath = strAddInName)) And (AD.Installed = False) Then | |
AD.Installed = True | |
isInstalled = True | |
ElseIf ((AD.Name = strAddInName) Or (ADPath = strAddInName)) And (AD.Installed = True) Then | |
isInstalled = True | |
End If | |
Next | |
' Überprüft die Existenz der Datei, wenn das Add-In nicht installiert ist | |
If isInstalled = False Then | |
Dim bFileExists As Boolean | |
bFileExists = (Dir(strAddInName) <> "") | |
' Verschiedene Pfade zur Dateisuche | |
If InStr(strAddInName, "\") = 0 Then | |
' Fügt Pfad hinzu, wenn nur Dateiname angegeben ist | |
Dim tmpFileName As String | |
tmpFileName = Convert2Directory(Application.LibraryPath) & strAddInName | |
If Not bFileExists And (Dir(tmpFileName) <> "") Then | |
strAddInName = tmpFileName | |
bFileExists = True | |
End If | |
' Sucht in einem alternativen Pfad | |
tmpFileName = Convert2Directory(Application.UserLibraryPath) & strAddInName | |
If Not bFileExists And Dir(tmpFileName) <> "" Then | |
strAddInName = tmpFileName | |
bFileExists = True | |
End If | |
End If | |
End If | |
' Lädt und installiert das Add-In, wenn es gefunden wurde | |
If Not isInstalled And bFileExists Then | |
Set AD = Application.AddIns.Add(Filename:=strAddInName) | |
AD.Installed = True | |
' Überprüft erneut, ob das Add-In jetzt installiert ist | |
For Each AD In Application.AddIns | |
ADPath = AD.Path & AD.Name | |
If ((AD.Name = strAddInName) Or (ADPath = strAddInName)) And (AD.Installed = True) Then | |
isInstalled = True | |
End If | |
Next | |
End If | |
' Gibt zurück, ob das Add-In erfolgreich aktiviert wurde | |
ActivateAddIn = isInstalled | |
End Function |
Mit folgender Funktion kann man ein Excel Addin deaktivieren:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Funktion zum Deaktivieren eines Add-Ins | |
Public Function DeactivateAddIn(strAddInName As String) As Boolean | |
Dim AD As AddIn | |
Dim isDeInstalled As Boolean | |
isDeInstalled = False | |
' Durchgeht jedes Add-In in der Anwendung | |
For Each AD In Application.AddIns | |
Dim ADPath As String | |
ADPath = AD.Path & "\" & AD.Name | |
' Deaktiviert das Add-In, wenn es installiert ist | |
If ((AD.Name = strAddInName) Or (ADPath = strAddInName)) And (AD.Installed = True) Then | |
AD.Installed = False | |
isDeInstalled = True | |
' Markiert als deaktiviert, wenn es nicht installiert war | |
ElseIf ((AD.Name = strAddInName) Or (ADPath = strAddInName)) And (AD.Installed = False) Then | |
isDeInstalled = True | |
End If | |
Next | |
' Gibt zurück, ob das Add-In erfolgreich deaktiviert wurde | |
DeactivateAddIn = isDeInstalled | |
End Function |
weiterführende Links: