View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Erich Neuwirth Erich Neuwirth is offline
external usenet poster
 
Posts: 41
Default Addin installation

The following code works

Sub Test1()
On Error Resume Next
AddIns.Add ( _
"C:\Documents and Settings\neuwirth\My Documents\MyTestAddin.xla")
If Err.Number < 0 Then
MsgBox Err.Number & " " & Err.Description
End If
AddIns("Mytestaddin").Installed = True
End Sub


The following code does NOT work, it breaks with Error 1004

Add method of Addins class failed


Sub Test2()
On Error Resume Next
Dim objExcelApp As Excel.Application
Set objExcelApp = New Excel.Application
objExcelApp.AddIns.Add _
"C:\Documents and Settings\neuwirth\My Documents\MyTestAddin.xla"
If Err.Number < 0 Then
MsgBox Err.Number & " " & Err.Description
End If
objExcelApp.AddIns("Mytestaddin").Installed = True
End Sub


Since I ultimately want to turn Test2 into a standalone VB application,
I need to know why it fails.
Is there a way of making it work?

When I try to run Test2 from Word
(with Excel not running) I get the same error.