Dim fso As New FileSystemObject
Dim oFile
Dim strAddInLoc As String
Dim ThisAddin As String
Dim i As Integer
'remove add-in from AddIns, if present
For i = 1 To AddIns.Count
If AddIns(i).Name = ThisAddin Then
AddIns.Remove (i)
Exit For
End If
Next i
' close add-in, if open
For i = 1 To Workbooks.Count
If Workbooks(i).Name = ThisAddin Then
Workbooks(i).Close
Exit For
End If
Next i
'copy & re-open
oFile.Copy strAddInLoc & oFile.Name, True
Set oFile = fso.GetFile(strAddInLoc & oFile.Name)
Workbooks.Open (oFile.Path)
Workbooks(oFile.Name).IsAddin = True
'install add-in
With Application.AddIns
.Add (oFile.Path)
.Item(ThisAddin).Installed = True
End With