Class AddIn (Word VBA)

The class AddIn represents a single add-in, either installed or not installed. The AddIn object is a member of the AddIns collection. The AddIns collection contains all the add-ins available to Microsoft Word, regardless of whether they are currently loaded. The AddIns collection includes global templates or Word add-in libraries (WLLs) displayed in the Templates and Add-ins dialog box.

The main procedures of class AddIn are Delete and AddIns.Add

Set

To use a AddIn class variable it first needs to be instantiated, for example

Dim adi as AddIn
Set adi = AddIns(Index:=1)

The following procedures can be used to set variables of type AddIn: AddIns.Add, AddIns.Item and Application.AddIns

For Each

Here is an example of processing the AddIn items in a collection.

Dim adi As AddIn
Dim iCount
For Each adi In AddIns
    If adi.Compiled = True And adi.Installed = True Then 
        iCount = iCount + 1 
    End If 
Next adi
MsgBox iCount & " WLL's are loaded"

Methods

These are the main methods of the AddIn class

Delete - Deletes the specified add-in.

AddIns(1).Delete

AddIns.Add - Returns an AddIn object that represents an add-in added to the list of available add-ins.

Dim strFileName As String: strFileName =  
Dim adi As AddIn
Set adi = AddIns.Add(FileName:=strFileName)

Properties

Autoload true if the specified add-in is automatically loaded when Word is started. Add-ins located in the Startup folder in the Word program folder are automatically loaded.

Dim booAutoload As Boolean
booAutoload = AddIns(1).Autoload

Compiled true if the specified add-in is a Word add-in library (WLL). False if the add-in is a template.

Dim booCompiled As Boolean
booCompiled = AddIns(1).Compiled

Index returns a Long that represents the position of an item in a collection.

Dim As Variant
AddIns(1).Index

Installed true if the specified add-in is installed (loaded). Add-ins that are loaded are selected in the Templates and Add-ins dialog box.

AddIns(1).Installed = True

Name returns the name of an add-in.

Dim strName As String
strName = AddIns(1).Name

Parent returns an object that represents the parent object of the specified AddIn object.

Dim objParent As Object
Set objParent = AddIns(1).Parent

Path returns the location of an installed add-in.

Dim strPath As String
strPath = AddIns(1).Path

AddIns.Count returns the number of AddIn objects in the AddIns collection.

Dim lngCount As Long
lngCount = AddIns.Count

AddIns.Parent returns an object that represents the parent object of the Addins collection. This is usually an Application object.

Dim objParent As Object
Set objParent = AddIns.Parent