0

I use this code to install an Add-in. But it does not seem to enable it. I get this error message:

Runtime error 1004: Unable to set the installed property of the add-in class.

My code:

Sub installatie_Click()

    Dim AI As Excel.AddIn
    Set AI = Application.AddIns.Add(Filename:="J:\Planning\Sjablonen\Updates\versieA.xlam")

    Application.AddIns("versieA").Installed = True
End Sub
6
  • Have you tried only with Application.AddIns("versieA").Installed = True? Commented Jan 14, 2020 at 9:24
  • @FoxfireAndBurnsAndBurns what is the difference between your code and my last line of code? Commented Jan 14, 2020 at 9:29
  • I guess the line that arises the error is Set AI = Application.AddIns.Add(Filename:="J:\Planning\Sjablonen\Updates\versieA.xlam"). I've got another add-ins in my machine, and to activate them my sub is just one line (Application.AddIns("versieA").Installed = True). I mean deleting the Dim and Setparts Commented Jan 14, 2020 at 9:31
  • Right, i tried it but i got the same error message. Commented Jan 14, 2020 at 9:33
  • You got the same error but on a different line? have you checked the add-in name is properly installed, enabled? (sometimes excel bloks some add-ins). Commented Jan 14, 2020 at 9:35

1 Answer 1

2

I always use to make my adding able to self install. Please try this code (in addin Workbook_Open event of its ThisWorkbook module): Your file may have a problem... You have to set its Title (BuiltinDocumentProperties(1)). Manually, right click on the addin file and modify (only with adding closed) or programatically (ThisWorkbook.BuiltinDocumentProperties(1) = "Whatever"), but without spaces..

Private Sub Workbook_Open()
  Dim Name As String, tmp As Boolean, n As Boolean, Merk As String
   Name = ThisWorkbook.BuiltinDocumentProperties(1)
   On Error Resume Next
   tmp = AddIns(Name).Installed
    If Err.number <> 0 Then
      Err.Clear: On Error GoTo 0
         If Workbooks.Count = 0 Then n = True
             If n Then
                 Workbooks.Add
                 Merk = ActiveWorkbook.Name
             End If
             AddIns.Add Filename:=ThisWorkbook.FullName
             AddIns(Name).Installed = True
             If n Then Workbooks(Merk).Close False
    End If
    On Error GoTo 0
End Sub
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.