Hide VBA procedures from Excel application but not

2019-07-02 11:11发布

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.

1条回答
▲ chillily
2楼-- · 2019-07-02 11:25
  • 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
查看更多
登录 后发表回答