Save & Install AddIn with VBA

  • Thread starter Thread starter Matt
  • Start date Start date
M

Matt

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top