WD: Macros to Generate List of Available Fonts In Word

Last reviewed: February 2, 1998
Article ID: Q92927
The information in this article applies to:
  • Microsoft Word for Windows, versions 1.0, 1.1, 1.1a, 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows 95, versions 7.0, 7.0a
  • Word for the Macintosh, versions 6.0, 6.0.1

SUMMARY

The following WordBasic macros generate a list of the fonts recognized by Microsoft Word and display a sample of each font.

The font list generated by this macro depends on the printer you select in the Printer dialog box.

MORE INFORMATION

Word 2.x, 6.x, 7.x

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.

Word 7.0 includes a FontSampleGenerator macro with Macros7.dot. Word 6.0 includes a FontSampleGenerator macro with Macros60.dot. The macro described below will also work with Word 6.0 and 7.0.

   Sub MAIN
      'speeds macro processing and suppresses display
      ScreenUpdating 0
      FileNew
      For count = 1 To CountFonts()
         FontName$ =  Font$(count)
         Font "Times New Roman", 12
         Insert FontName$ + Chr$(11)
         Font FontName$, 12
         Insert Chr$(9) + "abcdefghijklmnopqrstuvwxyz" + Chr$(11)
         Insert Chr$(9) + "0123456789?$%&()[]*_-=+/<>'" + Chr$(11) + \
         Chr$(11)
      Next count
   End Sub

NOTE: ScreenUpdating is for use with Word version 6.x and 7.x only. If you are using this macro with an earlier version of Word, eliminate the ScreenUpdating line.

CountFonts() returns the total number of fonts available to the selected printer. The For loop used above with CountFonts() sets up a loop that inserts the font names (FontName$) and the sample text.

For a macro to use with Microsoft Word 97 please see the following article in the Microsoft Knowledge Base:

   ARTICLE ID: Q170970
   TITLE     : WD97: Macro to Generate List of Available Fonts in Word

REFERENCE

"Using WordBasic," by WexTech Systems and Microsoft, pages 168 and 210


Additional query words: Font FontName$ sample
Keywords : kbmacroexample macword winword word6 word7 word95 kbmacro
Version : WINDOWS:2.x,6.0,6.0a,6.0c,7.0,7.0a; MACINTOSH:6.0,6.0.1
Platform : MACINTOSH WINDOWS
Issue type : kbhowto 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: February 2, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.