WD: WordBasic Macro for Numbering Rows of a Table

ID: Q89536

The information in this article applies to:

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 "The insertion point is not in a table cell"
      Else
         currow = SelInfo(13)
         TableSelectTable
         StartOfRow
         While SelInfo(12) = - 1
            StartOfLine
            InsertField .Field = "autonum"
            ' 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 "as is" 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.

REFERENCES

"Using WordBasic," WexTech Systems and Microsoft, pages 50, 239, 251, 257, 277-278, 291, 333

"Microsoft Word for Windows and OS/2 Technical Reference", pages 68- 69, 103-106, 203, 213, 223, 263, 286

Additional query words: automatic automatically records data

Keywords          : kbmacro wordnt winword kbmerge ntword macword kbtable word6 word7 word95 
Version           : WINDOWS:2.0,2.0a,2.0a-CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0,7.0a; MACINTOSH:6.0,6.0.1,6.0.6.0.1a
Platform          : MACINTOSH Win95 WINDOWS winnt
Issue type        : kbhowto

Last Reviewed: February 4, 1998