Table of contents
Collapse the table of content
Expand the table of content

Option Private Statement

office 365 dev account|Last Updated: 6/12/2017
1 Contributor

When used in host applications that allow references across multiple projects, Option Private Module prevents amodule's contents from being referenced outside its project. In host applications that don't permit such references, for example, standalone versions of Visual Basic, Option Private has no effect.


Option Private Module

Remarks If used, the OptionPrivate statement must appear atmodule level, before any procedures. When a module contains Option Private Module, the public parts, for example,variables, objects, and user-defined types declared at module level, are still available within theproject containing the module, but they are not available to other applications or projects.

NoteOption Private is only useful forhost applications that support simultaneous loading of multiple projects and permit references between the loaded projects. For example, Microsoft Excel permits loading of multiple projects and Option Private Module can be used to restrict cross-project visibility. Although Visual Basic permits loading of multiple projects, references between projects are never permitted in Visual Basic.


This example demonstrates the Option Private statement, which is used at module level to indicate that the entire module is private. With Option Private Module, module-level parts not declared Private are available to other modules in the project, but not to other projects or applications.

Option Private Module ' Indicates that module is private. 
© 2018 Microsoft