InfoConnect VBA Guide
Key Concepts / Understanding VBA Project Components
In This Topic
    Understanding VBA Project Components
    In This Topic

    Types of InfoConnect VBA Projects

    Each InfoConnect session document can include several types of VBA projects. These projects are displayed in the VBA Editor Project Explorer window.

     

    The Common Project

    Macros in the VBA Common project are available to all session documents. This is a useful place to save utility macros, macros that control the workspace (Frame object) settings, and other macros that are frequently used.

    Macros in the Common project can be called from any session code modules. For example, you could call the CopyScreenTextToClipboard macro from one of your session macros as follows:

    'Call a macro in the Common project from a session macro 
    Sub UseAMacroInTheCommonProject()
         Call CopyScreenTextToClipboard
     End Sub
    


    This project is always included. It can be used for macros that apply to the Frame object and to handle events (for example, the View_Opened event) on this object. Macros in this project are available to all session documents. When macros are saved in the Common project, you can call them from any of your session code modules. For example, you could call the CopyScreenTextToClipboard macro shown below from one of your session macros as follows:

    'Call a macro in the Common project from a session macro 
    Sub UseAMacroInTheCommonProject()
         Call CopyScreenTextToClipboard
     End Sub
    

     

    The Session and Legacy Session Projects

    InfoConnect creates a Desktop VBA project and a legacy VBA project for each session or Web document that you open in the Visual Basic Editor. (The legacy project contains older VBA macros migrated from legacy session documents when they were converted to Desktop sessions.)

    For session files created in InfoConnect Desktop 16.2 and greater,  Desktop VBA session projects have the same name as the session file name and legacy VBA project names have "Legacy" appended to the session file name. (In the example shown above, the DesktopVBA project is named mySession and the legacy project is named mySessionLegacy.) 

    Referenced Projects

    If the session has references to other session documents, the VBA projects in these session documents are imported and saved in the session file. These projects are updated every time the session is opened.

    SharedMacros Projects

    If the special session file named SharedMacros is in the user data folder, the macro projects in this file are imported to the session file. By default, these projects are named SharedMacros and SharedMacrosLegacy. 

    If you are referencing session documents or using SharedMacros files to share macros, make sure the projects in those files have unique project names. Each project name in the VBA Project editor must be unique to avoid errors caused by naming conflicts. You can change project names by modifying the project properties in the VBA editor or by creating and saving these files in InfoConnect Desktop 16.2 or greater.

    Components of InfoConnect VBA Projects

    Visual Basic projects are organized into the following folders:

    InfoConnect Objects

    The module that defines methods and properties for each InfoConnect object. Select an object in the Project Explorer to view its properties and options in the Properties window. For more information, see Using the InfoConnect Object Model.

    Forms*

    Custom dialog boxes that display information and get input from users.

    Modules

    Code modules that contain the programming procedures and declarations you have added to your project.

    You can create new modules (Insert > Module) or add your own procedures to an existing module. Double-click a module from the Project Explorer to display the code in the Code window.

    Note: This is the recommended location for creating macros.

    Class Modules*

    The programming feature for creating user-defined object classes, including methods and properties for these objects.

    References

    Specified projects from which you can run and make calls to macros. Any references you add to the project appear in this folder.

    Note: By saving macros to the Common project, you can share macros between projects without having to use references.

    *Present only if manually added to the project.