Chapter 15


Home

Chapter 1

Chapter 2

Chapter 3

Chapter 4

Chapter 5

Chapter 6

Chapter 7

Chapter 8

Chapter 9

Chapter 10

Chapter 11

Chapter 12

Chapter 13

Chapter 14

Chapter 15

Table of Contents


Programming in Word and Excel

Software is revised to add new features, fix bugs, or to completely change the way the program works.

WordBasic is used when you want to automate actions for many files or to customize a document.

When a Word macro is recorded, WordBasic commands are generated nd saved in the defaulttemplate, Normal.

Once a macro is recorded, it can be added to a menu or a toolbar.

The Do While and Do Until loops are the versatile indefinite loop structures of Visual Basic and BVA. Unfortunately, they are not available in WordBasic. The While ...Wend loop is the indefinite loop structure of WordBasic, a throwback to earlier versions of Basic

There are two data types in WordBasic, String adn Numeric. String variables are suffixed with a dollar sign. Numeric variables represent either whole number or decimals.

The InputBox$ and MsgBox$ functions work the same in WordBasic as they do in Visual Basic, as do the For-Next, the assignment statement, and the If-Then-Else-End If.

WordBasic uses the plus sign to join strings.

The Insert command inserts text into a document. The Insertpara command is equivalent to pressing the Enter key.

Visual Basic for Applications, or VBA, is the future of programming for Office. It is the language used to program Excel. It will be the language for all of Office and will be indistinguishable from Visual Basic.

A macro is a way to record a sequence keystrokes. Using Basic commands, macros can be enhanced to become entire application programs

A Macros are used to explore Basic code generated by events and commands within an application. To find out what code is generated when a file is saved, start recording a macro, save the file, and stop recording. Edit the macro to see what code has been produced. Every event and command has corresponding Basic code.

Macros in Word are saved in templates. Macros saved in the Normal template are global, available to every document created with that template.

In Excel, macros and Basic code are entered into modules. Each module is saved along wiht its workbook.

There are three ways to access cells in an Excel worksheet: A1, R1C1, and relative addressing. The A1 method is most familiar to Excel users. It assigns each column a letter (starting with A) and each row a number. The R1C1 method of addressing cells is used with some worksheets and facilitates automating repetitive actions with loops. Relative addressing is used when accessing a number of cells with a fixed relation of a known cell.

When designing documents where the alignment of elements is critical, use a nonproportionally spaced font, such as Courier New.

"Incremental programming" is a programming technique that starts with a minimal running program, and, as sections of code are added, makes sure the program still runs. This isolates problem areas in the code

Named Arguments are parameters sent to WordBasic commands.

The LTrim$() function trims blank characters from the front of a string. This is useful when building a pathname or cell address from a value by joining strings together.

ActiveCell returns the location of the cell that 's currently selected.

Application programs in both WordBasic and Excel are a combination of recorded macros and the programming that connect the pieces of the application together.