View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Huyeote[_11_] Huyeote[_11_] is offline
external usenet poster
 
Posts: 1
Default Difficulty in SaveAs an Addin


Hi all,

I have a workbook contains VBA code for work purpose and distribute it
to my collegues. I want to add code to either enable user to click a
button or even triggered by Workbook_Open event to save it as an Excel
addin and install it thereafter.

But I keep getting error message when I used different alternatives.

METHOD 1: AS FOLLOWING SIMPLE METHOD

Code:
--------------------

AddIns.Add(ThisWorkbook.FullName).Installed = True
--------------------


Excel returns Error 1004: Unable to copy add-in to liabrary. I guess
this is because our personal Addins folders are *hidden * and the Add
method can't access it.

METHOD 2: USING SAVEAS METHOD


Code:
--------------------
ThisWorkbook.SaveAs FileName:=fldr.Path & "\myAddin.xla" _
, FileFormat:=xlAddIn
AddIns("myAddin").Installed = True
--------------------

Note: fldr is a variable containing full path of the Addins folder.

This method yields Error 9: subscript out of range. When I manually
selete the addin file the code copied to liabrary folder
(Add-Ins...\Browse...), Excel said the file is not a valid add-in.

Any help on this annoying issue will be appreciated.

Thanks

Huyeote


--
Huyeote
------------------------------------------------------------------------
Huyeote's Profile: http://www.excelforum.com/member.php...o&userid=13894
View this thread: http://www.excelforum.com/showthread...hreadid=472498