Option Private Module Statement

Syntax

Option Private Module

Description

Restricts the scope and visibility of the contents of a module (i.e., its variables, classes, functions, and procedures) in VBA-enabled applications that allow references across multiple projects (e.g., Microsoft Office applications) to the module's project. Option Private Module has no effect in the standalone version of Visual Basic.

Rules at a Glance

• The Option Private Module statement must appear in the declarations section of a module before any procedures.

446 Chapter 7- The Language Reference

• Publicly declared procedures, variables, and objects contained within a module that has been set as private using the Option Private Module statement aren't available to other projects and applications. However, they are still available in the usual way to other members of the same project.

Programming Tips & Gotchas

You should only use the Option Private Module statement in applications such as Microsoft Excel that allow you to load multiple projects. In this way, the Option Private Module statement restricts visibility of publicly declared items.

Was this article helpful?

+2 0
Profit From Fiction

Profit From Fiction

Theres a lot of talk about just how lucrative the fiction genre is and how countless new writers are able to cash in with a combination of selfpublishing and hitting the right market.

Get My Free Ebook


Responses

  • ANDREA
    When to use option private?
    1 year ago
  • Fastolph
    Where is the modul option or modul 1 optioin in visual basic?
    6 months ago
  • lucas mayer
    How to turn on option private module in outlook vba?
    2 months ago

Post a comment