11 December 2009

View all installed fonts with Microsoft Word

It’s easy to preview fonts one by one in most applications, but what if you need to compare several fonts to pick one for a presentation of a blog design? Earlier this month, Lifehacker presented the application WinFontsView that displays all the fonts on your system on one screen, making the choice easier. Reading about it I remembered another solution that doesn’t involve a separate program: if you use Microsoft Word, a short macro can do the same job.

Simply open the Visual Basic Editor (the easiest way is to use a keyboard shortcut, Alt+F11, which works with both the classic and the new ribbon interface), insert a new module and then paste the Visual Basic code below:

Public Sub Display_Fonts()     
Dim Kracter As Variant, fnr As Integer
' prevent screen from updating during macro run
Application.ScreenUpdating = False
fnr = 0
For Each Kracter In FontNames
With Selection
fnr = fnr + 1 ' select next font
' write font name in document
.Font.Name = "Times New Roman"
.Font.Bold = True
.Font.Underline = wdUnderlineSingle
.TypeText fnr & ". " & Kracter
.InsertParagraphAfter
.MoveDown unit:=wdParagraph
Count = 1
Extend = wdMove
' write test characters with selected font
.Font.Bold = False
.Font.Underline = wdUnderlineNone
.Font.Name = Kracter
.TypeText "qwertyuioplkjhgfdsazxcvbnm aîstâ ßüöä"
.InsertParagraphAfter
.MoveDown unit:=wdParagraph
Count = 1
Extend = wdMove
' second test paragraph
.TypeText "1234567890`-=\[];',./~!@#$%^&*()_+|{}:<>?"
.InsertParagraphAfter
.MoveDown unit:=wdParagraph
Count = 2
Extend = wdMove
End With
Next Kracter
MsgBox "You have " & fnr & " fonts installed on your computer."
Application.ScreenUpdating = True
End Sub

You can always change the text in quotes after the .TypeText command if you want to compare a specific set of words or characters in different typefaces. Run the macro from the Visual Basic Window with F5 or in the Word document with Alt+F8 and the pages will fill with text in different fonts, like in the image below: Word display all fonts with macro

If Word refuses to run the code and pops up a message that the macros in the project are disabled, you need to change the macro security settings to “Medium” (e.g. in Word 2003 go to Tools ► Macro ► Security…). After version 2000, the default setting is “High”, which disables all untrusted macros and doesn’t even allow you to run code you’ve written yourself unless you sign it. With “Medium” however the user gets prompted every time the file is opened and can disable macros in third-party Word files to prevent potentially malicious code from running. Word macro security options

5 comments:

  1. I frequently work with emails. But yesterday I had an unpleasant problem with emails. My sister deleted whole my emails for seconds. Unfortunately I couldn't restore it instantly. Luckily for me several days ago I yesterday a next software - how to word corrup file open?. The application helped me for short time and free of cost.

    ReplyDelete
  2. This post helps you view all the fonts installed with Microsoft Word. You can clearly view the details. The logic of the program is bit difficult to understand. Microsoft Word provides wide variety of fonts so you have various options to choose. Thanks.

    ReplyDelete
  3. I realize this is an old post and HOPE you're still monitoring it! I need help. I'm trying to create a list of one-line quotes and I want each one to be in a different font. I have a hundred or more fonts on my computer. I just want a macro that will scroll through them and make the next paragraph in the next font. I don't want all the text to be the same. Is there a way to do this? Can you help? Please? Pretty please? :) Thanks in advance!!

    D.

    ReplyDelete
    Replies
    1. Hi Darlene!

      It should be pretty straightforward. Use the code below:

      Sub Format_Para()
      Dim i As Long, numP As Long
      numP = ActiveDocument.Paragraphs.Count
      For i = 1 To numP
      With ActiveDocument.Paragraphs(i).Range.Font
      .Name = FontNames(i)
      End With
      Next i
      End Sub

      Depending on how many paragraphs there are you might need to tweak the code to return to the first font and start over if you run out of fonts. Also I'm not quite sure which order Word uses for the fonts, in my case it started with Times New Roman, so it's probably not alphabetical. But for your use case that should be fine. Hope this works!

      Delete