Components

Importing and Exporting components is useful if you want to reuse a component from another project.
Every object in a project can be saved to a separate file.
Saving an individual object in a project is known as exporting.
This is useful if you want to use a particular object in a different project.
If you want to copy a module from one project to another you do not have to export and import each component.
If you open both projects you can use the Projects Explorer window to drag the components from one project to the other.


File Extensions

.frmA Userform file
.frxA Binary data file
.clsA Class module file
.basA Standard module file

Attributes

Attributes cannot be seen in the Visual Basic Editor.
Some attributes can be seen when you export a module to a text file.
Attributes can be used to set the name of a module or class, add descriptions to code resources, give classes a default global instance, set the default member of a class, and set a class's enumerator for use with For Each loops.

AttributeDescription
VB_NameUsed to set the name of the module or class.
VB_DescriptionUsed to set description text for modules, classes, procedures, and variables.
VB_PredeclaredIdSetting to True creates a default global instance of the class when the application starts.
VB_ExposedSetting to True makes a class type available outside of the VBA project. Objects of the class type can exist outside the VBA project but cannot be instantiated outside the VBA project. Instances created from an exposed class must be passed from a factory function defined within the VBA project.
VB_UserMemIdSetting to 0 makes the member the default member. Setting to -4 makes the member the enumerator of a class to be used with For Each loops.

VB_Name

This attribute can be used to set the name of a module or class.
This attribute can also be set in the Properties window in the Visual Basic Editor.


VB_Description

This attribute can be set description text for modules, classes, procedures, and variables.
When declaring the attribute for a module use the form "VB_Description".
When declaring the attribute for a procedure use the form "ProcedureName.VB_Description" inside the procedure.
When declaring the attribute for a variable use the form "VariableName.VB_VarDescription".


VB_PredeclaredId

This attribute can be used to create a default global instance of a class.
Setting this attribute to True will cause a global instance to be created when the application starts.


VB_Exposed

This attribute is used to specify the accessibility of a class.
Setting this attribute to True will make the class visible to outside VBA projects.
This has the same effect as setting the Instancing property of a class to PublicNotCreatable.
By default this property is set to False which makes the Instancing property Private.
PublicNotCreateable classes allow variables of the class type to be declared outside of the VBA project in which they are defined but objects of the class type cannot be instantiated outside the VBA project in which they are defined.


VB_UserMemId

This attribute can be used to set a default member of a class and to set an enumerator for a class to be used with For Each loops.


© 2025 Better Solutions Limited. All Rights Reserved. © 2025 Better Solutions Limited TopPrevNext