Register UDF with descriptions of arguments using excel addin

后端 未结 1 2094
我寻月下人不归
我寻月下人不归 2021-01-19 06:43

I have an addin with an UDF getRegExResult. I want to add a function description and arguments descriptions to this function, so when user installs the addin, c

相关标签:
1条回答
  • 2021-01-19 07:16

    Use the following code before setting the .MacroOption:

    Application.AddIns("Your Addin name").Installed = True
    

    This code may need to be preceded by :

    Application.AddIns("Your Addin name").Installed = False
    

    According to MSDN Blog, it is because automation loaded AddIns are not really opened at startup. So you have to close it before re-openning it.

    Note that "Your Addin name" is not the filename of the AddIn but its Name as it appears in the Add-ins option windows.

    Edit: Full code, don't forget to edit the AddIn name

    Public Sub getRegExResultRegister()
        Application.AddIns("Your Addin name").Installed = False
        Application.AddIns("Your Addin name").Installed = True
        Application.MacroOptions Macro:="getRegExResult", Description:="Returns a concatenated string of NONE, ONE, or ALL Regular Expression Match(es).", Category:="User Defined", _
            ArgumentDescriptions:=Array("Source string to inspect for matches.", _
            "Regular Expression Pattern. E.g. ""\d+"" matches at least 1 or more digits.", _
            "[Default = True] True = Returns all the matches found. False = Returns only the first match.", _
            "[Default = True] True = Not case sensitive search. False = Case sensitive search.", _
            "[Default = "";""] Delimiter to insert between every macth, if more than 1 matches are found.")
    End Sub
    
    0 讨论(0)
提交回复
热议问题