Chapter 26: Manipulating Visual Basic Components
In This Chapter
• Getting an overview of VBA Integrated Development Environment (IDE) and its object model
• Using VBA to add and remove modules from a project
• Writing VBA code that creates more VBA code
• Using VBA to help create UserForms
• Creating a UserForm on the fly
Introducing IDE
This chapter covers a topic that some readers might find extremely useful: writing VBA code that manipulates components in a VBA project. VBA Integrated Development Environment (IDE) contains an object model that exposes key elements of your VBA projects, including Visual Basic Editor (VBE) itself. This object model enables you to write VBA code that adds or removes modules, generates other VBA code, or even creates UserForms on the fly.
IDE is essentially an Object Linking and Embedding (OLE) automation interface for Visual Basic Editor. After you establish a reference to the object, you have access to all VBE objects, properties, and methods, and you can also declare objects from IDE member classes.
Use the VBE Tools⇒References command to display the References dialog box, where you can add a reference to Microsoft Visual Basic for Applications Extensibility Library (see Figure 26-1). This gives you access to an object called VBIDE. Creating a reference to VBIDE enables you to declare object variables contained in VBIDE and also gives you access to a number of predefined constants that relate to IDE. Actually, you can access the objects in ...
Get Excel 2013 Power Programming with VBA now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.