XL97: Changes to Microsoft Visual Basic for Applications

ID: Q161609

The information in this article applies to:

SUMMARY

The user interface for Microsoft Visual Basic for Applications in Microsoft Excel 97 has changed significantly from the interface for earlier versions of Microsoft Excel. This article describes the changes in the Visual Basic for Applications environment in Microsoft Excel 97.

MORE INFORMATION

The components that make up Microsoft Visual Basic for Applications are the Visual Basic Editor, the forms interface, and the Visual Basic for Applications language.

The Microsoft Visual Basic Editor

The Microsoft Visual Basic Editor (VBE) uses the familiar programming interface of Microsoft Visual Basic 4.0 as a base for creating and editing code. Within the VBE, there are five major elements: Project Explorer, Property Window, Code Window, Object Browser, and Debugging Tools.

One final change is that VBE operates in either Run Mode or Design Mode. Run mode is the default mode when a project is opened and is transparent to the user. Design Mode must be entered explicitly by clicking on the Design Mode button or clicking the Design Mode command on the Run menu. The main benefit of Design Mode is that it allows programmers to stop event handling routines from running automatically.

The Forms Interface

Earlier versions of Microsoft Excel used Dialogs on Dialog sheets to create custom forms. In Microsoft Excel 97, Dialog sheets are still available for backward computability. UserForms are now available for custom forms and can be used in Microsoft Excel 97, Microsoft Word 97, and Microsoft PowerPoint 97.

The advantages of UserForms are that they:

The Forms toolbar can be customized to display all registered OLE Custom Controls (OCX) in the system. The Forms toolbar can also have additional pages, controls can be moved from page to page, the bitmaps for the controls can be edited, and the tooltips can easily be changed.

Dragging a control from the form back to the toolbar creates a template of that control on the toolbar. For more information about creating a template for a control on the Forms toolbar, please see the following article in the Microsoft Knowledge Base:

     ARTICLE-ID: Q160473
     TITLE     : XL97: How to Create a Template for a Toolbox Control

The Microsoft Visual Basic for Applications Programming Language

- The Language

     Microsoft Visual Basic for Applications Programming developed for
     Microsoft Office 97 uses Microsoft Visual Basic 4.0 as its foundation.
     Many elements found in Visual Basic 4.0 are now incorporated into
     Visual Basic for Applications, such as user defined class modules,
     user defined collections, and custom properties.

     The three member types of all Visual Basic for Applications object
     models are Methods, Properties, and Events. Events have been expanded
     beyond the Click, Show, and Change events that were available in
     earlier versions of Microsoft Excel. Examples of new events are
     Activate, BeforeDoubleClick, SheetChange, Open, WindowActivate,
     MouseUp, MouseDown, and Calculate.

- Code Behind Objects
     Visual Basic for Applications also supports extended objects in
     Microsoft Excel 97. An extended object is an object that has code
     attached to it. Workbooks and worksheets can have code attached, as
     can controls and forms.

     Code behind objects uses extended objects to enhance Visual Basic for
     Applications programming by:

      - Directly and exclusively attaching a code module to an object.
      - Directly attaching forms to an object.
      - Using Properties and Methods of the object without need for the
        name of the object to which the code is attached.
      - Providing a unified user model for writing event handling code for
        the object and for the controls inside the object.

     There are several advantages to code behind objects. Code is moved,
     copied, and saved with the object to which it is attached. Simpler
     syntax can be used to refer to properties and methods of the objects
     because the code is attached to the object. For example, in earlier
     versions of Microsoft Excel, if programming code referred to
     "Worksheets("Sheet1")" and Sheet1 was renamed to "First Sheet", all
     code referring to Sheet1 would generate an error. With code attached
     to the object, when Sheet1 is renamed, the code attached to it still
     runs without you having to edit the code.

REFERENCES

For more information about new features, click the Index tab in Microsoft Excel Help, type the following text

   new, features

and then double-click the selected text to go to the "What's new in Microsoft Excel 97" topic.

Additional query words: XL97 97 VBA VBE VB Editor project explorer

Keywords          : kbprg kbui kbdta xlui KbVBA 
Version           : WINDOWS:97
Platform          : WINDOWS

Last Reviewed: May 17, 1999