Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/105549

From BetaArchive Wiki

WordBasic Error with Array Dimensioned for 0 (Zero) Elements


The information in this article applies to:

  • Microsoft Word for Windows, versions 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows, version 7.0


If you dimension an array with no elements using a statement such as Dim Array$(-1), a WordBasic error occurs when you run the macro. This problem did not occur in Word version 2.x for Windows.

As a result, if your macro dimensions an array based on a count, the macro fails if the count is 0 (zero). For example, the following macro will fail if the last FileFind statement finds no matches:

   Dim Array$(CountFoundFiles() - 1) 

This also means you cannot display an empty list box in a dialog box; it must always contain one empty element.


We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.


You must rewrite your macro so it contains no arrays with 0 elements. For example, use the following statement to dimension an array that contains an extra element:

   (Dim a$(countfoundfiles())) 

When you write a new macro, check to be sure your array will not contain 0 elements.


An array in WordBasic has as many elements as its last index plus 1, which means that an array dimmed as 0 actually has one element. Therefore, Dim Array$(-1) dimensions an array with no elements.

Kbcategory: kbusage kbmacro

Additional query words: 6.0 winword word6 7.0 word95 word7

Keywords :
Issue type :
Technology :

Last Reviewed: November 4, 2000
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.