Welcome toWord.Tips.Net
Ask a Word Question
Make a Comment
Learn Access Now
Free Printable Forms
Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Legal Tips
Money Tips
Organizing Tips
Pest Tips
Pet Tips
Wedding Tips
Word2007 Tips
WordTips
Collapsing and Expanding Subdocuments
In Word 6 or Word 95, macros are written in a language called WordBasic. This is a specialized version of the BASIC programming language, and as such, allows you to use variables. Variables are nothing but names which represent other data. During the course of your macro you can even change the data to which the name applies.
There are two types of variables you can use in your macros. The first is numeric variables. Numeric variables are designated by names that end in either a number or letter, and can contain numeric data, i.e. numbers. The values assigned to numeric variables can be either whole numbers or numbers that have fractional values, as well. If you are familiar with other programming languages, numeric variables in WordBasic are double-precision, floating-point variables. This means they are accurate to about 15 decimal places.
The other type of variables are string variables. String variables have names that end in a dollar sign, and they can contain any type of text or character you desire. You can assign a maximum of 32,767 such characters to a string variable.
WordBasic also supports the use of variable arrays, which are nothing but entire groups of related data which are referred to by the same variable name. Arrays can be used either for strings or numeric data. For instance, consider the following part of a macro:
Dim Name$(5) Name$(1) = "Mary" Name$(2) = "George" Name$(3) = "Kris" Name$(4) = "Harry" Name$(5) = "Anna"
The first line in this code, which uses the Dim statement, declares the array. In this case, the Name$() array is declared to have five elements, numbered 1 through 5. The next five lines assign values to each of the elements in this array. Arrays such as this are helpful when you are processing large amounts of related data. (Purists will point out, however, that under normal circumstances this array will have six elements, since WordBasic starts arrays at 0. Thus, there are elements 0 though 5.)
Tip #117 applies to Microsoft Word versions: 6 95
Create Rock-Solid Lists! Bulleted and numbered lists can help make your writing clearer and easier to follow. If not done properly, however, they can be a nightmare to work with. Discover the ins and outs of Word's lists with this great reference available in two versions.