Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Difficulty in SaveAs an Addin

Hi Huyeote,

Hope this helps.

1. Start the Visual Basic Editor by pressing Alt+F11.
2. Select Debug, Compile VBA projectname. In previous versions of Excel the
VBA-code was automatically compiled when you saved the addin. This is no
longer true, you have to do it yourself before you save the addin.
3. If you want to lock the project from viewing you can select Tools,
Properties for VBA projectname.
4. In this dialog you activate Protection and check the option Lock project
for viewing.
5. Fill in a password and click the OK-button.
6. Activate Excel by pressing Alt+F11.
7. Select File, Properties..., Summary and fill inn information for the
fields Title and Comments.
8. The title will be the name that appears in the Add-Ins dialog (the dialog
displaying available add-ins),
the comment will be the description that appears when you select the addin
in the 9. Add-Ins dialog.
10. Click the OK-button to close the Properties dialog.
11. Select File, Save as€¦.
12. Change the option Filetype: to Microsoft Excel addin (*.xla) (the last
choice in the dropdown).
13. The add-in must contain at least one worksheet if this option is to be
displayed.
Click the Save-button to save the workbook as an addin.

"Huyeote" wrote:


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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Difficulty in SaveAs an Addin


Thanks Mel, but my problem is with using a VBA code to save it as a
Excel add-in. Currently I use the same prcess as yours to save it as
add-in and documented it to allow my users to do the same thing. But
when I write code in the project to save Thisworkbook as an add-in,
Excel either tells me the file can't be copied to liabrary or doesn't
recoginse it as a valid add-in after copy. Can you help on the code and
tell me what's wrong with the code?

BTW, my Excel's version is XP (2002)
Operating system is Windows 2000 Terminal

Thanks,

Huyeote


Mel Arquiza Wrote:
Hi Huyeote,

Hope this helps.

1. Start the Visual Basic Editor by pressing Alt+F11.
2. Select Debug, Compile VBA projectname. In previous versions of Excel
the
VBA-code was automatically compiled when you saved the addin. This is
no
longer true, you have to do it yourself before you save the addin.
3. If you want to lock the project from viewing you can select Tools,
Properties for VBA projectname.
4. In this dialog you activate Protection and check the option Lock
project
for viewing.
5. Fill in a password and click the OK-button.
6. Activate Excel by pressing Alt+F11.
7. Select File, Properties..., Summary and fill inn information for
the
fields Title and Comments.
8. The title will be the name that appears in the Add-Ins dialog (the
dialog
displaying available add-ins),
the comment will be the description that appears when you select the
addin
in the 9. Add-Ins dialog.
10. Click the OK-button to close the Properties dialog.
11. Select File, Save as€¦.
12. Change the option Filetype: to Microsoft Excel addin (*.xla) (the
last
choice in the dropdown).
13. The add-in must contain at least one worksheet if this option is to
be
displayed.
Click the Save-button to save the workbook as an addin.




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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Difficulty in SaveAs an Addin

Hi Huyeote,

If you follow all this steps below in this weblink:

http://www.exceltip.com/st/How_to_Us...n_VBA/630.html

The problem next could be your Office XP Service Packs (SP3) not updated no
also sure.

Where is the code?

"Huyeote" wrote:


Thanks Mel, but my problem is with using a VBA code to save it as a
Excel add-in. Currently I use the same prcess as yours to save it as
add-in and documented it to allow my users to do the same thing. But
when I write code in the project to save Thisworkbook as an add-in,
Excel either tells me the file can't be copied to liabrary or doesn't
recoginse it as a valid add-in after copy. Can you help on the code and
tell me what's wrong with the code?

BTW, my Excel's version is XP (2002)
Operating system is Windows 2000 Terminal

Thanks,

Huyeote


Mel Arquiza Wrote:
Hi Huyeote,

Hope this helps.

1. Start the Visual Basic Editor by pressing Alt+F11.
2. Select Debug, Compile VBA projectname. In previous versions of Excel
the
VBA-code was automatically compiled when you saved the addin. This is
no
longer true, you have to do it yourself before you save the addin.
3. If you want to lock the project from viewing you can select Tools,
Properties for VBA projectname.
4. In this dialog you activate Protection and check the option Lock
project
for viewing.
5. Fill in a password and click the OK-button.
6. Activate Excel by pressing Alt+F11.
7. Select File, Properties..., Summary and fill inn information for
the
fields Title and Comments.
8. The title will be the name that appears in the Add-Ins dialog (the
dialog
displaying available add-ins),
the comment will be the description that appears when you select the
addin
in the 9. Add-Ins dialog.
10. Click the OK-button to close the Properties dialog.
11. Select File, Save as€¦.
12. Change the option Filetype: to Microsoft Excel addin (*.xla) (the
last
choice in the dropdown).
13. The add-in must contain at least one worksheet if this option is to
be
displayed.
Click the Save-button to save the workbook as an addin.




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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Difficulty in SaveAs an Addin


Thanks for your link, I've fixed the problem. Just need to change the
value of Thisworkbook.IsAddin property to False before copying the
workbook over to add-in liabrary.

For your information, following is the final code I use.

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

ThisWorkbook.IsAddin = True 'set IsAddin property to true

ThisWorkbook.SaveAs FileName:=fldr.Path & "\myAddin.xla" _
, FileFormat:=xlAddIn
--------------------


Strangely, without tweaking *IsAddIn * property, the -FileFormat -
parameter in *SaveAs * Method doesn't help at all even when you specify
the format as -xlAddIn-. I could copy over the file to personal Addin
folder but Excel couldn't recognise it as a valid addin. Problem was
fixed after I change the IsAddin Property of the workbook. Do you know
why?

Thanks,

Huyeote


Mel Arquiza Wrote:
Hi Huyeote,

If you follow all this steps below in this weblink:

http://www.exceltip.com/st/How_to_Us...n_VBA/630.html

The problem next could be your Office XP Service Packs (SP3) not
updated no
also sure.

Where is the code?




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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difficulty in transposing Richard J New Users to Excel 12 August 6th 06 09:53 AM
difficulty with permutations, please help! Loane Sharp[_2_] Excel Programming 2 August 9th 05 05:32 PM
saveas addin from VBA Dave Ring Excel Programming 3 July 18th 04 12:45 PM
Remove Excel AddIn from AddIn List !! Help carl Excel Programming 2 December 8th 03 03:36 PM
Difficulty with code Tom Ogilvy Excel Programming 3 August 29th 03 04:09 AM


All times are GMT +1. The time now is 12:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"