View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Hayes0 Hayes0 is offline
external usenet poster
 
Posts: 2
Default Save & Install AddIn with VBA

Something like


Sub SaveAddIn()
Dim MyName As String, Shortname As String, MyPAth As
String
Dim MyAddIn as String, xlAddIn as AddIn
Application.DisplayAlerts = False
With ThisWorkbook
MyName=.Name
Shortname=replace(MyName,".xls","")
MyAddin=Shortname & ".xla"
'Save as Add in
MyPAth = .Path & "\"
.IsAddin = True
.SaveAs Filename:=MyPAth & MyAddIn,
FileFormat:=xlAddIn
'Save as Workbook again otherwise you won't be able to
see the sheets
.IsAddin = False
.SaveAs MyPAth & Shortname & ".xls",
addtoMRU:=True
End With



On Error resume next
'De Install it
Application.Addins(MyaddIn).Installed=false
'Re Install it
Set xlAddIn=Application.Addins.Add (Mypath &
MyAddIn,true)
xlAddIn.Installed=true
On error goto 0
Application.DisplayAlerts = True
End Sub


-----Original Message-----
I'm trying to write code to save an activeworkbook as an
addin and then install the addin just saved. Can anyone
help me with this?

Thanks,
Matt
.