Excel VBA Programming For Dummies. Dick Kusleika
Чтение книги онлайн.

Читать онлайн книгу Excel VBA Programming For Dummies - Dick Kusleika страница 17

Название: Excel VBA Programming For Dummies

Автор: Dick Kusleika

Издательство: John Wiley & Sons Limited

Жанр: Программы

Серия:

isbn: 9781119843092

isbn:

СКАЧАТЬ style="font-size:15px;">      
You can’t run the VBE separately; Excel must be running for the VBE to run.

      Activating the VBE

      The quickest way to activate the VBE is to press Alt+F11 from an Excel window. To return to Excel, press Alt+F11 again. Or you can simply click the Close button on the VBE’s title bar. When the VBE window closes, Excel becomes the active window.

      You can also activate the VBE by choosing Developer ⇒ Code ⇒ Visual Basic. If you don’t have a Developer tab at the top of your Excel window, refer to Chapter 2, which shows how to get that handy Developer tab to show up.

      Exploring VBE components

Snapshot of VBE is your customizable friend.

      FIGURE 3-1: The VBE is your customizable friend.

      Menu bar

      The VBE menu bar contains commands you can use to do things with the various components in the VBE. Many of the menu commands have shortcut keys associated with them.

      

The VBE also features shortcut menus. You can right-click virtually anything in the VBE and get a shortcut menu of common commands.

      Toolbar

      The Standard toolbar, which is directly below the menu bar by default (refer to Figure 3-1), is one of the four VBE toolbars. You can customize the toolbars, move them around, display other toolbars, and more. To do so, choose View ⇒ Toolbars, and customize as you see fit. Most people just leave them as they are.

      Project Explorer

      The Project Explorer displays a tree diagram that shows every workbook currently open in Excel (including add-ins and hidden workbooks). Double-click items to expand or contract them within the outline. See the upcoming “Working with the Project Explorer” section for more detail.

      If the Project Explorer is not visible, press Ctrl+R or choose View ⇒ Project Explorer. To hide the Project Explorer, click the Close button on its title bar. Or right-click anywhere in the Project Explorer and choose Hide from the shortcut menu.

      Code pane

      A Code pane is where you put your VBA code. Every object in a project has an associated Code pane. To view an object’s Code pane, double-click the object in the Project Explorer. For example, to view the Code pane for the Sheet1 object in Book1, double-click Sheet1 in the VBAProject for Book1. Unless you’ve added some VBA code, the Code pane is empty.

      You find out more about Code panes later in this chapter’s “Working with a Code Pane” section.

      Immediate window

      The Immediate window may or may not be visible. If it isn’t visible, press Ctrl+G or choose View ⇒ Immediate Window. To close the Immediate window, click the Close button on its title bar (or right-click anywhere in the Immediate window and choose Hide from the shortcut menu).

      GETTING HELP IN THE VBE

      Beginning with Excel 2013, all VBA help information is on the internet and is displayed in your web browser. In other words, you must be connected to the internet to access the Help system. You can, however, download your very own copy of the Help system from Microsoft’s site. Do a web search for download excel VBA documentation, and you’ll find it. Pick the link at microsoft.com and don’t worry if the version they have is a few versions older than yours — they don’t update it all that often.

      Chapter 13 covers the Immediate window in detail. It may just become your good friend!

      In the VBE, workbooks are called projects. Every workbook contains exactly one project, and every project is associated with exactly one workbook. A project holds all the modules and keeps them neatly in folders that tell you what kind of module it is. There are four kinds of modules, each kind in its own folder:

       Microsoft Excel Objects: These are modules that are linked to user interface elements like workbooks and worksheets. See Chapter 11 for more about these types of modules.

       Modules: Excel calls these simply modules, but everyone else refers to them as standard modules or VBA modules. These contain the code that doesn’t go in any of the other three module types.

       Forms: These are modules that have a form user-interface. Chapter 16 provides an introduction to UserForms.

       Class Modules: These are modules where you create your own objects. Class modules are beyond the scope of this book.

      You can expand a project by clicking the plus sign (+) at the left of the project’s name in the Project Explorer. Collapse a project by clicking the minus sign (–) to the left of a project’s name. Or you can double-click a project’s name to expand and collapse it.

If a project is password-protected, the VBE prompts for its password when you double-click the project’s name. If you don’t know the password, you can’t expand the project — which means that you can’t view or modify any part of the project.

СКАЧАТЬ