Programmatically Save Excel Add-In

Tom picture Tom · Dec 22, 2010 · Viewed 7.9k times · Source

I have a worksheet updated occasionally by users that is used to make an Add-In (.XLAM). The Add-In is located on a network share and users link to it. I am looking to enable users to easily update this add-in (ensuring it is marked as read only)

I have seen the article by Ken Puls here on deploying Excel Add-Ins however the .SaveCopyAs method he uses doesn’t seem to be able to accept a file type.

The .SaveAs method does, however when this was tried I gota message saying the file format or extension was invalid, I have tried both with .XLAM and .XLA as below.

DeployPath = "C:\Menu.xlam"
.SaveAs Filename:=DeployPath, ReadOnlyRecommended:=True, FileFormat:=xlOpenXMLAddIn

Any help in this regard would be greatly appreciated.

Answer

Charles Williams picture Charles Williams · Dec 22, 2010

I think that you need to use (Excel 2003 and earlier)

ThisWorkbook.IsAddin = True
ThisWorkbook.SaveAs "fredyy", xlAddIn

For Excel 2007+ use

ThisWorkbook.SaveAs "fredyy", xlOpenXMLAddIn