Class AddIns (Word VBA)

A collection of AddIn objects that represents all the add-ins available to Word, regardless of whether or not 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. To use a AddIns class variable it first needs to be instantiated, for example


Dim ais as AddIns
Set ais = AddIns

For Each

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


Dim adi As AddIn
For Each adi In AddIns
	
Next adi

Add

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

Use the Installed property of an add-in to see whether it is already installed.

Add (FileName, Install)


Sub AddTemplate() 
 ' For this example to work correctly, verify that the 
 ' path is correct and the file exists. 
 
 AddIns.Add FileName:="C:\Program Files\Microsoft Office" _ 
 & "\Templates\Letters & Faxes\MyFax.dot", Install:=True 
End Sub

Arguments

The following argument is required

FileName (String) - The path for the template or WLL.

Optional arguments

The following argument is optional

Install (Boolean) - True to install the add-in. False to add the add-in to the list of add-ins but not install it. The default value is True.

Count

Returns the number of AddIn objects in the AddIns collection.


Dim lngCount As Long
lngCount = AddIns.Count

Item

Returns an individual object in a collection.

Item (Index)

Index: The individual add-in to be returned. Index can be an Long indicating the ordinal position of the add-in in the collection or a String representing the name of the individual add-in.


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

Unload

Unloads all loaded add-ins and, depending on the value of the RemoveFromList argument, removes them from the AddIns collection.

To unload a single template or WLL, set the Installed property of the AddIn object to False. To remove a single template or WLL from the AddIns collection, apply the Delete method to the AddIn object.

Unload (RemoveFromList)

RemoveFromList: True to remove the unloaded add-ins from the AddIns collection (the names are removed from the Templates and Add-ins dialog box). False to leave the unloaded add-ins in the collection. If the Autoload property for an unloaded add-in returns True, Unload cannot remove that add-in from the AddIns collection, regardless of the value of RemoveFromList.


If AddIns.Count > 0 Then AddIns.UnLoad RemoveFromList:=False