View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default MacroOptions doesn't stick

Greg

when your workbook has IsAddin = true you must
fully qualify the function's address (include the addin's name)

dont use the addin_install event, that's only triggered when the addin
is activated via the dialog. instead use workbook_open


Private Sub Workbook_Open()
Dim itm, arr
arr = Array("Function1", "Function2")
On Error Resume Next
For Each itm In arr
Application.MacroOptions ThisWorkbook.Name & "!" & itm, Category:="My
Category"
If Err Then Debug.Print "oops:", itm
Next

End Sub

Also note that I've left the descriptive text out of the macro:
To add descriptive text to functions I prefer to add them
via the Object Browser... so they are stored with the code.

Open Object Browser.
Select the project of your addin.
(your addin must be the active project!)

Select <globals
Select the function.., right click and select properties


now add the description
the box is a bit small but never mind.

to enter linebreaks use ctrl+Enter.
Since you cannot add descriptions for arguments, (laurent longre has a
solution for that) you could add some extra text on line 2/3 of the
description.

Note the function wizard allows for 3 lines of text, but in the object
browser (at the bottom) you'll see only 2 lines.


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Greg Lovern wrote :

I have an add-in with custom functions. I'm trying to use
MacroOptions to add descriptions for them in the Insert Function
dialog, and to create custom categories for them, and put them in the
custom categories.

It works fine if I just run the code and then look at the Insert
Function dialog. But if I exit and restart Excel (2003), the custom
category is gone and the custom function is listed in the Engineering
category (I have no idea why it gets put there).

I tried putting the code in the Workbook_AddinInstall event, and
unchecking the Add-in from the Add-Ins dialog and then rechecking it.
Again, works fine until I restart Excel, then it's back to the same
problem.

I tried the putting it in the Workbook_Open event, but that gives me
an error message about not being able to edit a hidden workbook. I
tried putting it in the main module's auto_open (which otherwise
works fine), but it doesn't seem to do anything there.

Any idea what I need to do differently? My code is like this:

Application.MacroOptions "MyFunction", "This is the description for
MyFunction.", , , , , "My Category"


Thanks,

Greg