在 Excel VBA 中,如何访问存储在已安装加载项中的子程序?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4066171/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 12:14:57  来源:igfitidea点击:

In Excel VBA, how to access subs stored in an installed Add-In?

excelvba

提问by xiaodai

I have create an Excel Add-In. In that add-in are some modules and let's say module1 is one them. In module1 I have a sub declared as public sub abc() end sub

我已经创建了一个 Excel 加载项。在该加载项中有一些模块,假设 module1 就是其中之一。在 module1 我有一个 sub 声明为 public sub abc() end sub

In my workbook I want to be able to use the function abc defined in the add in. It doesn't seem to work!

在我的工作簿中,我希望能够使用插件中定义的函数 abc。它似乎不起作用!

E.g. I install the Addin so that now it appears in the VBAProject sections. I create a sub in my main workbook (this is not the add-in workbook) and have a sub called def says

例如,我安装了 Addin,以便它现在出现在 VBAProject 部分中。我在我的主工作簿(这不是加载项工作簿)中创建了一个子程序,并且有一个名为 def 的子程序说

sub def()
  call abc
end sub



sub def1()
  call module1.abc
end sub

Neither of these work. Please help.

这些都不起作用。请帮忙。

采纳答案by Lance Roberts

You have to make sure the Add-in has a project name, then reference it through the Tools > References dialog. See this linkfor more details.

您必须确保加载项具有项目名称,然后通过“工具”>“引用”对话框引用它。有关更多详细信息,请参阅此链接