ID: Q109570
The information in this article applies to:
When you open Newmacro.doc, included with Word for Windows 2.0, you may receive the following WordBasic error message when the AutoOpen macro runs:
WordBasic Err=9 Subscript out of range.
This problem does not occur when you open the NewMacro.doc file in Word 97.
Instead Word 97 alerts you that the macros will not be converted when you
open the template in Word 97.
The "Subscript out of range" error message refers to an array element with a subscript outside the defined dimensions of the array, or an array element that has the wrong number of subscripts. For example, the subscript for the array element variable "Item$(2)" is 2, which means the element is to occupy the third position in the array. If the array has been dimensioned to contain only one element, as in the statement "Dim Item$(0)," specifying the variable "Item$(2)" in the macro will generate the "Subscript out of range" error message because it references a third position in the array when there is only one position available.
In the case of Newmacro.doc, the AutoOpen macro searches for the number of macros in the document and loads an array with the macro names. If the number of macros that begin with "Auto" in NEWMACRO.DOC is not exactly 22, you may receive the "Subscript out of range" error message. The following line in the AutoOpen macro should be adjusted to correspond to 2 less than the total number of macros in NEWMACRO.DOC that begin with "Auto":
cAutoMacros = 20
Change the number in the cAutoMacros=20 line to 2 less than the total number of macros in Newmacro.doc that begin with "Auto."
For example, if you delete the macro "AutoFootnoteEntry," there will be a total of 21 macros in NEWMACRO.DOC that begin with "Auto." To prevent the "Subscript out of range" error message, change the above macro line to:
cAutoMacros = 19
"Using WordBasic," by WexTech Systems, page 341
"Microsoft Word Developer’s Kit," version 6.0 for Word 6.0 for Windows, page 829
KBCategory: kbusage kbmacro kberrmsg KBSubcategory: Additional query words: winword2 2.0 2.0a 2.0b 2.0c 2.0a-CD 6.0 winword 6.0a 6.0c 7.0 word95 word7 word6 7.0a
Version : 2.x 6.0 6.0a 6.0c 7.0 7.0a
Platform : WINDOWS
Last Reviewed: February 5, 1998