EXCEL Addin – XLL中的方法

如何知道我的XLL模块中有哪些方法可用,以防我需要在VBA代码中使用/调用其中的任何方法。

我可以通过调用:

Application.Run() 

方法,其中我必须传递我的macros名称作为参数。

我的问题是关于这个macros名称:我怎么知道我的XLL插件中存在哪些macros。

任何帮助表示赞赏。

干杯!!!!!!!!!!! 图莎尔

您可以使用Application.RegisteredFunctions方法为您提供Excel注册的XLL中的函数列表。

例如,以下代码将列出当前注册的XLL的XLL,函数名称和参数types:

 Public Sub ListRegisteredXLLFunctions() Dim RegisteredFunctions As Variant Dim i As Integer RegisteredFunctions = Application.RegisteredFunctions If IsNull(RegisteredFunctions) Then Exit Sub Else Dim rng As Range Set rng = Range("A1") Set rng = rng.Resize(UBound(RegisteredFunctions, 1), UBound(RegisteredFunctions, 2)) rng.Value = RegisteredFunctions End If End Sub 

你是从代码POV问这个问题吗? 如果你只是想手工检查出来,你可以在项目浏览器中看到。 否则,我会build议只是试图运行macros,但如果macros不存在,使用error handling程序。

 On Error GoTo badMacroCall application.run(myMacro) badMacroCall: msgbox("That macro could not be run!")