Skip to main content

Option Private statement

Table of contents
  1. Syntax
  2. Remarks
  3. Example

When used in host applications that allow references across multiple projects, Option Private Module prevents a module'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


If used, the Option Private statement must appear at the module level, before any procedures.

When a module contains Option Private Module, the public parts, for example, variables, objects, and user-defined types declared at the module level, are still available within the project containing the module, but they are not available to other applications or projects.


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.

Leave a comment

Your email address will not be published. Required fields are marked *

Format your code: <pre><code class="language-vba">place your code here</code></pre>