Microsoft KB Archive/89536

{|
 * width="100%"|

WD: WordBasic Macro for Numbering Rows of a Table

 * }

Q89536

-

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 NT, version 6.0
 * Microsoft Word for Windows, versions 7.0, 7.0a
 * Microsoft Word for the Macintosh, versions 6.0, 6.0.1

-

SUMMARY
The following Microsoft WordBasic sample macro numbers each of the rows in a table. The macro inserts an AutoNum field at the beginning of the first cell in each table row.

  Sub Main If SelInfo(12) <> - 1 Then MsgBox &quot;The insertion point is not in a table cell&quot; Else currow = SelInfo(13) TableSelectTable StartOfRow While SelInfo(12) = - 1 StartOfLine InsertField .Field = &quot;autonum&quot; ' Move down to next row (row may have more than one line) oldrow = currow While currow = oldrow LineDown 1 currow = SelInfo(13) Wend Wend End If  End Sub In order to insert a tab after the number, add the following macro instruction after the InsertField statement in the above macro example:

   Insert Chr$(9) NOTE: Microsoft provides macros &quot;as is&quot; without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purposes.