Collections (Visual Basic Add-In Model)

A collection is an object that contains a set of related objects. An object's position in the collection can change whenever a change occurs in the collection; therefore, the position of any specific object in the collection can vary.

The following sections describe the collections in the Visual Basic Add-In Model.

AddIns

Returns a collection of add-ins registered for VBA.

Syntax

object.AddIns

Remarks

The AddIns collection is accessed through the VBE object. Every add-in listed in the Add-In Manager in VBE has an object in the AddIns collection.

CodePanes

Contains the active code panes in the VBE object.

Remarks

Use the CodePanes collection to access the open code panes in a project.

Use the Count property to return the number of active code panes in a collection.

CommandBars

Contains all of the command bars in a project, including command bars that support shortcut menus.

Remarks

Use the CommandBars collection to enable add-ins to add command bars and controls, or to add controls to existing, built-in, command bars.

LinkedWindows

Contains all linked windows in a linked window frame.

Remarks

Use the LinkedWindows collection to modify the docked and linked state of windows in the development environment.

Important

Objects, properties, and methods for controlling linked windows, linked window frames, and docked windows are included on the Macintosh for compatibility with code written in Windows. However, these language elements will generate run-time errors when run on the Macintosh.

The LinkedWindowFrame property of the Window object returns a Window object that has a valid LinkedWindows collection.

Linked window frames contain all windows that can be linked or docked. This includes all windows except code windows, designers, the Object Browser window, and the Search and Replace window.

If all the panes from one linked window frame are moved to another window, the linked window frame with no panes is destroyed. However, if all the panes are removed from the main window, it isn't destroyed.

Use the Visible property to check or set the visibility of a window.

Use the Add method to add a window to the collection of currently linked windows. A window that is a pane in one linked window frame can be added to another linked window frame. Use the Remove method to remove a window from the collection of currently linked windows; this results in the window being unlinked or undocked.

The LinkedWindows collection is used to dock and undock windows from the main window frame.

Properties

Represents the properties of an object.

Remarks

Use the Properties collection to access the properties displayed in the Properties window. For every property listed in the Properties window, there is a Property object in the Properties collection.

References

Represents the set of references in the project.

Remarks

Use the References collection to add or remove references. The References collection is the same as the set of references selected in the References dialog box.

See also the VBProject object.

VBComponents

Represents the components contained in a project.

Remarks

Use the VBComponents collection to access, add, or remove components in a project. A component can be a form, module, or class. The VBComponents collection is a standard collection that can be used in a For...Each block.

Use the Parent property to return the project that the VBComponents collection is in.

For more information, see the VBComponents property and the VBProject object.

VBNewProjects

Represents all of the new projects in the development environment.

Remarks

Use the VBNewProjects collection to access specific projects in an instance of the development environment. VBNewProjects is a standard collection that you can iterate through by using a For...Each block.

VBProjects

Represents all the projects that are open in the development environment.

Remarks

Use the VBProjects collection to access specific projects in an instance of the development environment. VBProjects is a standard collection that can be used in a For...Each block.

Windows

Contains all open or permanent windows.

Remarks

Use the Windows collection to access Window objects.

The Windows collection has a fixed set of windows that are always available in the collection, such as the Project window, the Properties window, and a set of windows that represent all open code windows and designer windows.

Opening a code or designer window adds a new member to the Windows collection. Closing a code or designer window removes a member from the Windows collection. Closing a permanent development environment window doesn't remove the corresponding object from this collection, but results in the window not being visible.

See also

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.