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
Setting Fraction Bar Overhang Spacing in the Equation Editor
Printing On Both Sides of the Paper
Turning Off AutoComplete for Dates
Understanding Auto Line Spacing
Adding Comments to Your Document
Conditional Calculations in Word
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
Find and Replace Almost Anything! An invaluable resource for learning how to harness the full power of Word's search and replace capabilities. You'll discover everything you need in order to master all the intricacies of finding and replacing elements of your document, including the super-powerful "wildcard searches" available in Word.