Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

How to install an Excel Add-in (XLA or XLL) with Automation


View products that this article applies to.

Summary

This article illustrates how to install an Excel Add-in (xla or xll) with Automation.

↑ Back to the top


More information

The following code demonstrates how to use Automation to:
  • Add a new workbook.
  • Call the Add method of the AddIns collection to add the new add-in to the list of add-ins in Excel Add-In Manager.
  • Set the Install property of the AddIn object to True (equivalent to selecting the add-in the Add-in Manager).
    Dim oXL As Object, oAddin As Object
    Set oXL = CreateObject("Excel.Application")
    oXL.Workbooks.Add
    Set oAddin = oXL.AddIns.Add("C:\test.xla", True)
    oAddin.Installed = True
    oXL.Quit
    Set oXL = Nothing
    					
    Note that a workbook is added prior to calling the Add method in this example. The Add-in Manager in Excel is not available unless there is at least one visible workbook open. Without this line of code, you receive one of the following error messages:
    Run-time error '1004':
    Unable to get the Add property of the AddIns class
    -or-
    Run-time error '1004':
    Add method of addins class failed.

↑ Back to the top


References

For more information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
161439 XL97: How to Remove Entries from Add-Ins Dialog Box
211956 XL2000: Cannot Delete Entries from Add-Ins Dialog Box

↑ Back to the top


Keywords: KB280290, kbprogramming, kbhowto, kbautomation

↑ Back to the top

Article Info
Article ID : 280290
Revision : 7
Created on : 6/10/2005
Published on : 6/10/2005
Exists online : False
Views : 628