WD: WordBasic Macro for Numbering Rows of a Table

ID: 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 95, 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 "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 : MACINTOSH:6.0,6.0.1; WINDOWS:2.0,2.0a,2.0a-CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0,7.0a; winnt:6.0
Platform : MACINTOSH WINDOWS winnt
Issue type : kbhowto


Last Reviewed: December 28, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.