WD: WordBasic Macro for Numbering Rows of a Table

Last reviewed: February 2, 1998
Article 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 : kbmerge kbtable macword ntword winword word6 word7 word95 wordnt kbmacro
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


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 2, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.