Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default Addin installation

Erich,

This is from a small VB app which does just what you are after. I think the
problem might be that you have to have a workbook open in order to install
an add-in. Don't ask why. The use of app.path below is possible because this
program is installed to the same folder as the add-in itself. Try running
your Excel version with no workbook open to see if you get the error.

Private Sub Form_Load()
Dim oAddin As Object
Dim oXL As Object
Set oXL = CreateObject("Excel.Application")
Dim strPath As String
oXL.Workbooks.Add
strPath = App.Path & "\XspandXL.xla"
Set oAddin = oXL.ADDINS.Add(strPath)
oAddin.installed = True
oXL.Quit
Set oXL = Nothing
Unload Me
Call MsgBox("XspandXL should launch automatically the next time that you
restart Excel", _
vbOKOnly, "XspandXL")
End Sub

HTH,

Robin Hammond
www.enhanceddatasystems.com

"Erich Neuwirth" wrote in message
...
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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Addin installation

This did the trick,
I only added
oXL.DisplayAlerts = False

to avoide the save file dialiog when closing Excel.
I also founf the following link
http://www.codeguru.com/vb/gen/vb_mi...cle.php/c2735/
very useful, it allows to use command line parameters,
so one can write a generic installer which takes the name
of the addin to be installed from the command line.

Now I would like to know:
Is there a similar way to UNINSTALL an addin?

oXL.ADDINS.REMOVE(strPath)
does not exist.
oAddin.installed = False works.
Just deleting the addin file, however,
will produce an error when the
Addin dialog is opened from Excel.



Robin Hammond wrote:

Erich,

This is from a small VB app which does just what you are after. I think the
problem might be that you have to have a workbook open in order to install
an add-in. Don't ask why. The use of app.path below is possible because this
program is installed to the same folder as the add-in itself. Try running
your Excel version with no workbook open to see if you get the error.

Private Sub Form_Load()
Dim oAddin As Object
Dim oXL As Object
Set oXL = CreateObject("Excel.Application")
Dim strPath As String
oXL.Workbooks.Add
strPath = App.Path & "\XspandXL.xla"
Set oAddin = oXL.ADDINS.Add(strPath)
oAddin.installed = True
oXL.Quit
Set oXL = Nothing
Unload Me
Call MsgBox("XspandXL should launch automatically the next time that you
restart Excel", _
vbOKOnly, "XspandXL")
End Sub

HTH,

Robin Hammond
www.enhanceddatasystems.com

"Erich Neuwirth" wrote in message
...

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.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Addin installation



I've got a VB6 routine that just reads and manipulates the various
registry keys, saves you plenty of hassle.. PLUS it installs for every
version of excel installed on the system ..Does remove too :)

The only drawback it that excel must be closed.
if interested please mail.


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Erich Neuwirth wrote :

This did the trick,
I only added
oXL.DisplayAlerts = False

to avoide the save file dialiog when closing Excel.
I also founf the following link
http://www.codeguru.com/vb/gen/vb_mi...cle.php/c2735/
very useful, it allows to use command line parameters,
so one can write a generic installer which takes the name
of the addin to be installed from the command line.

Now I would like to know:
Is there a similar way to UNINSTALL an addin?

oXL.ADDINS.REMOVE(strPath)
does not exist.
oAddin.installed = False works.
Just deleting the addin file, however,
will produce an error when the
Addin dialog is opened from Excel.



Robin Hammond wrote:

Erich,

This is from a small VB app which does just what you are after. I
think the problem might be that you have to have a workbook open in
order to install an add-in. Don't ask why. The use of app.path
below is possible because this program is installed to the same
folder as the add-in itself. Try running your Excel version with no
workbook open to see if you get the error.

Private Sub Form_Load()
Dim oAddin As Object
Dim oXL As Object
Set oXL = CreateObject("Excel.Application")
Dim strPath As String
oXL.Workbooks.Add
strPath = App.Path & "\XspandXL.xla"
Set oAddin = oXL.ADDINS.Add(strPath)
oAddin.installed = True
oXL.Quit
Set oXL = Nothing
Unload Me
Call MsgBox("XspandXL should launch automatically the next time
that you restart Excel", _
vbOKOnly, "XspandXL")
End Sub

HTH,

Robin Hammond
www.enhanceddatasystems.com

"Erich Neuwirth" wrote in message
...

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.





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
addin for excel installation Kardock Setting up and Configuration of Excel 0 February 13th 09 07:44 PM
Problems with AddIn Installation Stephen Bullen[_3_] Excel Programming 0 June 24th 04 01:07 AM
AddIn installation problem ale036 Excel Programming 0 June 22nd 04 08:58 PM
AddIn installation Problems ale036 Excel Programming 0 June 22nd 04 07:37 PM
AddIn installation Problems cescobar Excel Programming 0 June 22nd 04 07:36 PM


All times are GMT +1. The time now is 04:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"