WordBasic: Determining the Number of Records in Data Source

Last reviewed: August 5, 1997
Article ID: Q123691
The information in this article applies to:
  • Microsoft Word for Windows, versions 6.0, 6.0a, 6.0c

SUMMARY

When you are writing a macro, you may need to know how many records are in the attached mail merge data source. This article lists a sample macro that you can use to determine the number of records in the attached data source.

MORE INFORMATION

Run the following macro from the main document to determine the number of records in the attached data source.

WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

   Sub MAIN
   If MailMergeMainDocumentType() <> - 1 Then
    MailMergeLastRecord
    MsgBox Str$(MailMergeGoToRecord()) + " records"
   End If
   End Sub

The MailMergeLastRecord statement displays the last record in the data source if there are no query options. The MailMergeGoToRecord() function returns the number of the displayed record.

Kbcategory: kbusage kbmacro KBSubcategory:


Additional reference words: 6.0 6.0a 6.0c winword word6
Version : 6.0 6.0a 6.0c
Platform : WINDOWS


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: August 5, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.