Chapter 26. Programming the VBE

Up until now, the book has focused on writing VBA procedures to automate Excel. While writing the code, you have been working in the Visual Basic Editor (VBE), otherwise known as the Visual Basic Integrated Design Environment (VBIDE).

An object library is provided with Office 2007 that is shown as Microsoft Visual Basic for Applications Extensibility 5.3 in the VBE's Tools

Programming the VBE
  • Programmatically create, delete, and modify the code, UserForms, and references in your own and other workbooks

  • Program the VBE itself to create useful Add-ins to assist you in your development efforts and automate many of your development tasks


There have been no significant changes to the Visual Basic for Applications Extensibility library between Office 2000 and Office 2007, so all the examples in this chapter apply equally to all versions.

The only responsible way to start this chapter is with a warning. Macro viruses work by using the methods shown in this chapter to modify the target file's code, thus infecting it. To prevent this, Microsoft has made it possible to disable access to all workbooks' VBProjects. By default the access is disabled, so none of the code in this chapter will work. To enable access to the VBProjects, place a check mark next to the Trust Access to the VBA Project Object Model checkbox in Excel 2007's Office Menu

This chapter explains how to write code ...

Get Excel® 2007 VBA Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.