Err Msg: WordBasic Err=9 in NEWMACRO.DOC

Last reviewed: February 5, 1998
Article ID: Q109570
The information in this article applies to:
  • Microsoft Word for Windows, versions 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows 95, versions 7.0, 7.0a

SYMPTOMS

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.

CAUSE

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

RESOLUTION

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

REFERENCES

"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


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 5, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.