WD: Macros to Generate List of Available Fonts In Word

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
  • Microsoft 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.

NOTE: Word 6.x for Windows and Word for Windows 95 (7.0) provide a FontSampleGenerator macro you can use to generate a sample document that you can print out to show all printable fonts on your system in the point size you specify.

For additional information about the FontSampleGenerator macro, please see the following articles in the Microsoft Knowledge Base:

Q105765 Macros in the CONVERT, LAYOUT, TABLES, and MACRO60 Templates

Q172380 WD95: Macros in CONVERT7, LAYOUT7, TABLES7, and MACROS7 Template


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.

   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:
Q170970 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 : kbmacro kbmacroexample winword macword word6 word7 word95
Version : MACINTOSH:6.0,6.0.1; WINDOWS:1.0,1.1,1.1a,2.0,2.0a,2.0a-CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0,7.0a
Platform : MACINTOSH WINDOWS
Issue type : kbhowto kbinfo


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