Register UDF with descriptions of arguments using excel addin

£可爱£侵袭症+ 提交于 2019-12-01 20:11:47

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!