Getting Help with VBA

I can't emphasize enough how important it is that you become comfortable with the on-line help in the VBA IDE (not to mention in the Excel application). The on-line help provides fast access to solutions for any programming problems you have with your project. Books make good resources and are much better at teaching you how to program, but they can't cover everything. Often, all you need to see is a simple example of how to use a particular function or other keyword; the on-line help does contain documentation on every keyword, programming construct, and object you might use in your project. The bottom line is this: there is always something helpful on-line, it's just a matter of finding the right document.

The Color Changer program.

VBA Help

Using the on-line help with VBA subject matter is identical to using the on-line help in Excel. To access the VBA help, you must have the IDE open and active; otherwise, everything is the same, from the Help menu to the help window and even the office assistant (if you choose to use it). Select Help, Microsoft Visual Basic Help to activate the Visual Basic Help dialog box shown in Figure 1.15. With the Visual Basic Help dialog you can browse a table of contents or enter keywords to search for on-line documentation. After you select a topic, documentation related to that topic appears in another Visual Basic Help window (for example, refer to Figure 1.16).

To Look up documentation concerning a known keyword in VBA (for example, the syntax requirements for a particular VBA keyword), first select that keyword in the code, press Fl, and the document that describes that keyword will immediately appear in the Help window.

You will not have on-line help with your VBA projects until you install these VBA help files with a custom installation. Refer to the Installing and Enabling VBA section earlier in this chapter to learn how to install the VBA help files.

The Color Changer program.

The Visual Basic Help dialog box.

Visual Basic Help


Table of Contents

^Microsoft Excd Visual Basic Reference Microsoft Excel Oblect Model What's New (^Programming Concepts

Ijjj Workbooks and Worksheets <£j} Creeling a New Workbook

Opening a Workbook iff: Referring to Sheets by Index Number

Referring to Sheets by Mame (^Saving Documents as Web Pages 'jj^Cells and Ranges -¡^Controls., Dialog Boxes, and Forms > si Events, Worksheet Functions, and Shapes Working with Other Applications ^Cotertions ^Objects -^Methods ^Properties ^Events ^Enumerations ■ tf' Microsoft Visual Basic Etocumentation •^Microsoft Offte Vlsuef Basic Reference

The Visual Basic

Help dialog window showing a help document.

© Microsoft Visual Bjsir Help

Creating a Mew Workbook

See Also anew workbook in Visual Basic, use the Add method. The foflowrig procedure creates a new workbook- Microsoft Excel automaticaly names the workiook. Book/l/, where JVe the next available nyrrfcer. The new workbook becomes the active wcfk&ook

Workbooks.Add End Sub

A better way to create a new workbooks to assign t to an object variable. In the foBcwna example, the Workbook cbject returned by the Add method b essigned to an object variable, newBook Next, several properties v newBook are set, You can easiy control the new workbook using the object variable.

3ub AddJJew(>

Set JfewBook = Workbooks.Add Kith HewBook

.Title - "All Sales" - Subject = "Sales^ -SaveAs FilejtaiEe: = ,,A.LLsales. xls" End With End Sub

Was this article helpful?

0 0
Biorhythm Awareness

Biorhythm Awareness

Who else wants to take advantage of biorhythm awareness to avoid premature death, escape life threatening diseases, eliminate most of your life altering mistakes and banish catastrophic events from your life.

Get My Free Ebook

Post a comment