从Excel应用程序隐藏VBA程序,但不从其他项目 [英] Hide VBA procedures from Excel application but not from other projects

查看:152
本文介绍了从Excel应用程序隐藏VBA程序,但不从其他项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是一个漫长的过程,但是在选项专用模块中甚至更糟糕的是私有子/功能的限制,有谁知道是否存在从Excel应用程序隐藏VBA过程而不是从其他项目?



我有一个可重用功能的子集的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆