Using Arrays in Names

A name can also store the data stored in an array. The array size is limited to 256 columns and 5,461 total elements. See Chapter 16, "Automating Word," for more information on arrays.

An array reference is stored in a name the same way as a numeric reference.

Sub NamedArray() Dim myArray(10, 5) Dim i As Integer, j As Integer 'The following For loops fill the array myArray For i = 1 To 10 For j = 1 To 5

'The following line takes our array and gives it a name Names.Add Name:="FirstArray", RefersTo:=myArray End Sub

Because the name is referencing a variable, no quotes or equal signs are required.

0 0

Post a comment