The following code will install an addin to the users local addins folder. There are two constants that need to be changed, well only one really if your installing a .xla. You will also need to modify the call to "Addcustommenu" which appears twice - make a call to your menu/entry points code.
The code actually saves a copy of it’s self into the users adding folder, this make it good for deployment over a network.
I use this code in conjunction with some modified code from JKP apps set up utility.
Const gsFilename As String = gsAppName & ".xla"
'---------------------------------------------------------------------------------------
' Procedure : auto_open
' DateTime : 02/03/2006 11:17
' Author : rmclean
' Purpose : Installs Addin to local addins folder
' Version : v1
'---------------------------------------------------------------------------------------
'
Sub auto_open()
On Error GoTo ErrorHander
''exit if in degub mode
If Dir(ThisWorkbook.Path & "\debug.ini") <> "" Then
Exit Sub
End If
If UCase(ThisWorkbook.FullName) = _
UCase(Application.LibraryPath & "\" & gsFilename) Then
On Error Resume Next
AddIns.Add (Application.LibraryPath & "\" & gsFilename)
AddIns(gsAppName).Installed = True
On Error GoTo ErrorHander
Call Addcustommenu ''CHANGE AS NEEDED
Exit Sub
Else
'opens a workbook in case
Workbooks.Add
'closes any workbook with the same name
On Error Resume Next
Workbooks(gsFilename).Close False
On Error GoTo ErrorHander
ThisWorkbook.SaveAs Filename:=Application.LibraryPath & "\" & gsFilename _
, FileFormat:=xlAddIn
AddIns.Add (Application.LibraryPath & "\" & gsFilename)
AddIns(gsAppName).Installed = True
End If
Call Addcustommenu ''CHANGE AS NEEDED
Exit Sub
ErrorHander:
MsgBox "An error 'appen, when i wrote this code I didn't thing this would happen. The error was: " _
& vbNewLine & vbNewLine _
& Err.Description & vbNewLine & vbNewLine _
& "Can you tell Ross Mclean about this. thanks", Title:=gsAppName, Buttons:=vbOKOnly
End Sub
where can I put the code? In which event of my .xla?
Private Sub Workbook_Open() ?
Private Sub Workbook_Activate()
Private Sub Workbook_AddinInstall()
I'm searching code for "a double-click self installing .xla file"
thanks a lot.
Just stick it in a stanard modual, it will run automatically when the workbook is open,
You may have to change a few bits of the code