WD: Determining the Current Page and Section Number w/ WordBasic

Last reviewed: March 4, 1998
Article ID: Q81791
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
  • Word for the Macintosh, versions 6.0, 6.0.1

SUMMARY

In Microsoft Word, you can use the WordBasic SelInfo function to return information about the current selection. For example, you can use the SelInfo function to determine the current page and section number for the insertion point position or the selected text. The SelInfo() function is not available in Word for Windows version 1.x.

MORE INFORMATION

The following macro posts the current page and section number in a message box:

   Sub MAIN
      Section = SelInfo(2)
      Page = SelInfo(3)  'Physical page number
      MsgBox "Page" + Str$(Page) + Chr$(160) + "Section" + Str$(Section)
   End Sub

The syntax for SelInfo() is as follows:

   n = SelInfo(Type)

There are 36 different arguments or types for the SelInfo function in Word 6.0 (30 arguments in Word version 2.x). Type number 2 returns the section number containing the selection. Type number 3 returns the physical page number in the document containing the selection. Type number 1 returns the logical page number for the current page. In otherwords, physical page 4 may be logical page number 23.

REFERENCES

"Using WordBasic," by WexTech Systems and Microsoft, page 277


Additional query words:
Keywords : kbmacroexample macword ntword winword word6 word7 word95 wordnt
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 : kbinfo


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