Option Private Module causes Implicitly Public #5928
-
Currently I use subs and functions from different modules in my VBA excel add in. Currently i do this using option private module. This keeps everything out of the macro list but still lets me use functions and subs with the normal syntax. However when a module is Option Private Module inspections for Implicitly Public are still triggered when in fact the subs and functions are private. Is this intended behavior and/or is there a better way to do this? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This is intended behaviour, indeed. What The inspection warns about something different. If you do not specify an access modifier ( It is good practice to make anything private that can be private and to explicitly mark the members intended to be public as public. |
Beta Was this translation helpful? Give feedback.
This is intended behaviour, indeed.
What
Option Private Module
does is the following. Usually, public members in standard modules can be referenced from any other VBA project with a reference to the current project. When the option is set, this is no longer possible. Only other components in the current project can reference the public members in the module.In Excel, there is the further effect that the public members no longer appear in the macros dialog.
The inspection warns about something different. If you do not specify an access modifier (
Private
,Public
,Friend
) for a member of a component, it is implicitly public, i.e. accessible from anywhere in the project. This is not affected…