Word

List all available Font names with example text in table.

Ease of Use

Easy

Version tested with

2000, 2003 

Submitted by:

MOS MASTER

Description:

Programmatically list all available Font names and example data to a table in a newly created document. 

Discussion:

You really need a nice font for the text you want to edit in Word, but it takes to much time to set each font one after the other to view the results. This sub creates a table with a full list of installed fonts on your computer and has example text so you can see what font to use for the job. 

Code:

instructions for use

			

Option Explicit Sub ListAllFonts() Dim oDoc As Word.Document Dim oTable As Word.Table Dim iCnt As Long If MsgBox("Do you wish to build a list?" & vbCr & _ "Building a list on older systems this may take a while" & vbCr & _ vbCr & "Screen may appear frozen" & vbCr & _ "Please wait for the list to complete", _ vbQuestion + vbYesNo, "Built Font list") = vbYes Then Application.ScreenUpdating = False 'Create new doc to list font's Set oDoc = Application.Documents.Add 'Create table of 2 columns and as many rows as there are fontnames Set oTable = oDoc.Tables.Add(Range:=Selection.Range, _ NumRows:=Application.FontNames.Count + 1, _ NumColumns:=2) With oTable 'Create table header With .Cell(1, 1).Range .Font.Name = "Arial" .Font.Bold = True .InsertAfter "Font Name" End With With .Cell(1, 2).Range .Font.Name = "Arial" .Font.Bold = True .InsertAfter "Font Example" End With 'Loop through Fontnames For iCnt = 1 To Application.FontNames.Count 'Add Fontname to cell With .Cell(iCnt + 1, 1).Range .Font.Name = "Arial" .Font.Size = 10 .InsertAfter Application.FontNames(iCnt) End With 'Set Font in Cell to Fontname and insert example text With .Cell(iCnt + 1, 2).Range .Font.Name = Application.FontNames(iCnt) .Font.Size = 10 .InsertAfter "ABCDEFG 1234567890 hijklmnop" End With Next iCnt 'No borders and sort table Ascending .Borders.Enable = False .Sort SortOrder:=wdSortOrderAscending End With End If End Sub

How to use:

  1. Open your Word document.
  2. Press Alt + F11 to open VBE.
  3. Insert-Module. (Insert -> module)
  4. Paste the code there in the window at right. (F7)
  5. Close VBE (Alt + Q or press the X in the top right hand corner).
  6. Save the file.
 

Test the code:

  1. From Word, press Alt + F8 to open the macro dialog box.
  2. Select ListAllFonts
  3. Click Run.
 

Sample File:

List all installed fonts on computer.zip 11.41KB 

Approved by mdmackillop


This entry has been viewed 115 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express