Features of WordBasic

WordBasic is a structured programming language originally modeled on the Microsoft QuickBasic™ language. It combines a subset of the instructions available in standard Basic languages with statements and functions based on the Word user interface. You can use WordBasic to modify any Word command or to write your own. You can assign your macros to menus, toolbars, and shortcut keys so that they look and function like regular Word commands.

WordBasic includes the following features for developing macros.

Macro-editing environment

The macro-editing environment includes tools for testing and debugging macros. For example, buttons on the Macro toolbar can step and trace through macros, show current variable values in a paused macro, and "comment out" instructions (Chapter 2, "Getting Started with Macros," and Chapter 6, "Debugging").

Control structures

WordBasic supports most of the standard Basic control structures, including If¼Then¼Else, For¼Next, While¼Wend, and Select Case (Chapter 3, "WordBasic Fundamentals," and Chapter 4, "Advanced WordBasic").

Subroutines and user-defined functions

By writing subroutines and defining functions, you can create modular code that is easy to test. You can also store libraries of subroutines and functions that can be used in more than one macro (Chapter 4, "Advanced WordBasic").

Dialog Editor

You can use the Dialog Editor included with Word to design custom dialog boxes that support most of the standard dialog box controls in the Microsoft Windows family of operating systems and the Apple Macintosh System 7 operating system. The Dialog Editor automatically creates the WordBasic instructions that define your custom dialog box (Chapter 5, "Working with Custom Dialog Boxes").

DDE and OLE Automation

To communicate with other applications, Word supports dynamic data exchange (DDE) and provides partial support for OLE Automation (Chapter 8, "Communicating with Other Applications").

Extensibility

In Windows, you can extend WordBasic's capabilities by calling functions stored in dynamic-link libraries (DLLs) and Word add-in libraries (WLLs), as well as functions available through the Windows application programming interface (API). On the Macintosh, you can call functions stored in Word add-in libraries, and you can run AppleScript scripts from within WordBasic (Chapter 9, "More WordBasic Techniques").