从Excel应用程序隐藏VBA程序,但不从其他项目 [英] Hide VBA procedures from Excel application but not from other projects
问题描述
我有一个可重用功能的子集的XLAM,我喜欢从新的Excel项目中包含和引用,但使用Option Private Module阻碍了这一点,如果我省略它,一堆不可用或者模糊的函数和subs变得可见并可用于应用程序。
- 将XLAM中的标准模块转换为类模块(设置为
Public Not Creatable ); - 创建一个附加的类模块返回每个这样的模块的实例(
位的附加工作,实例);和 - 创建一个标准模块,其中一个属性返回主类入口模块的实例。
Class1:
Option Explicit
Public Sub IAmInvisible()
End Sub
ModuleEntry:
Option Explicit
私有mClass作为新Class1
公共属性将TheClass()作为Class1
设置TheClass = mClass
结束属性
I know this is a long shot, but with the limitations in "Option Private Module" and even worse "Private Sub/Function", does anyone know if there is a way of hiding VBA procedures from the Excel application but not from other projects?
I have an XLAM with a subset of reusable functionality that I like to include and reference from new Excel projects, but using "Option Private Module" hinders this and if I omit it, a bunch of unusable or obscure functions and subs become visible and available to the application.
- Convert your standard modules in the XLAM to class modules (set to Public Not Creatable);
- Create an additional Class Module that returns an instance (with a bit of additional work, the instance) of each such module; and
- Create a single standard module with one property that returns the instance of the main class-entry module.
Class1:
Option Explicit
Public Sub IAmInvisible()
End Sub
ModuleEntry:
Option Explicit
Private mClass As New Class1
Public Property Get TheClass() As Class1
Set TheClass = mClass
End Property
这篇关于从Excel应用程序隐藏VBA程序,但不从其他项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!