Objects (Visual Basic Add-In Model)
The AddIn object provides information about an add-in to other add-ins.
An AddIn object is created for every add-in that appears in the Add-In Manager.
You use the CodeModule object to modify (add, delete, or edit) the code associated with a component. Each component is associated with one CodeModule object. However, a CodeModule object can be associated with multiple code panes.
The methods associated with the CodeModule object enable you to manipulate and return information about the code text on a line-by-line basis. For example, you can use the AddFromString method to add text to the module. AddFromString places the text just above the first procedure in the module or places the text at the end of the module if there are no procedures.
Represents a code pane.
Use the CodePane object to manipulate the position of visible text or the text selection displayed in the code pane.
You can use the Show method to make the code pane you specify visible.
Use the SetSelection method to set the selection in a code pane.
Use the GetSelection method to return the location of the selection in a code pane.
The CommandBar object contains other CommandBar objects, which can act as either buttons or menu commands.
The CommandBarEvents object is returned by the CommandBarEvents property of the Events object.
The object that is returned has one event in its interface, the Click event. You can handle this event by using the WithEvents object declaration.
The Events object provides properties that return event source objects. Use the properties to return event source objects that notify you of changes in the Visual Basic for Applications environment.
The properties of the Events object return objects of the same type as the property name. For example, the CommandBarEvents property returns the CommandBarEvents object.
Use the Value property of the Property object to return or set the value of a property of a component.
At a minimum, all components have a Name property. The Value property returns a Variant of the appropriate type. If the value returned is an object, the Value property returns the Properties collection that contains Property objects representing the individual properties of the object. You can access each of the Property objects by using the Item method on the returned Properties collection.
If the value returned by the Property object is an object, you can use the Object property to set the Property object to a new object.
Use the Reference object to verify whether a reference is still valid.
The IsBroken property returns True if the reference no longer points to a valid reference.
The BuiltIn property returns True if the reference is a default reference that can't be moved or removed.
Use the Name property to determine if the reference you want to add or remove is the correct one.
Returned by the ReferencesEvents property.
The ReferencesEvents object is the source of events that occur when a reference is added to or removed from a project.
The ItemAdded event is triggered after a reference is added to a project.
The ItemRemoved event is triggered after a reference is removed from a project.
Use the VBComponent object to access the CodeModule object associated with a component or to change a component's property settings.
You can use the Type property to find out what type of component the VBComponent object refers to.
You can use the following collections to access the objects contained in the VBE object:
Use the VBProjects collection to access the collection of projects.
Use the AddIns collection to access the collection of add-ins.
Use the Windows collection to access the collection of windows.
Use the CodePanes collection to access the collection of code panes.
Use the CommandBars collection to access the collection of command bars.
Use the Events object to access properties that enable add-ins to connect to all events in Visual Basic for Applications. The properties of the Events object return objects of the same type as the property name. For example, the CommandBarEvents property returns the CommandBarEvents object.
You can use the SelectedVBComponent property to return the active component. The active component is the component that is being tracked in the Project window. If the selected item in the Project window isn't a component, SelectedVBComponent returns Nothing.
All objects in this object model have a VBE property that points to the VBE object.
Represents a project.
Represents a window in the development environment.
Use the Window object to show, hide, or position windows.
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.
|Window||Result of using Close method|
|Code window||Removes the window from the Windows collection.|
|Designer||Removes the window from the Windows collection.|
|Window objects of type linked window frame||Windows become unlinked separate windows.|
Using the Close method with code windows and designers actually closes the window. Setting the Visible property to False hides the window but doesn't close the window. Using the Close method with development environment windows, such as the Project window or Properties window, is the same as setting the Visible property to False.
You can use the Visible property to return or set the visibility of a window.
To find out what type of window you are working with, you can use the Type property. If you have more than one window of a type, for example, multiple designers, you can use the Caption property to determine the window you are working with.
- Objects (Microsoft Forms)
- Objects and collections (Visual Basic for Applications)
- Visual Basic Add-in Model reference
- Visual Basic language reference
- Office client development reference
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.