Did you ever want to see all the fonts that you have installed displayed in Word with some sample text? No, well I did and I didn’t feel like doing it manually. I’m sure there is some font program that already does this, but wanted to be able to run a simple macro each time rather than having to install something.
Anyway, after an hour or so, I came up with the following:
[code]
Dim allfonts(400) As String
Dim thefont As String
Set fontlist = Application.CommandBars(“Formatting”).FindControl(ID:=1728)
‘ If Font control is missing, create a temp CommandBar
If fontlist Is Nothing Then
Set TempBar = Application.CommandBars.Add
Set fontlist = TempBar.Controls.Add(ID:=1728)
End If
For i = 0 To fontlist.ListCount – 1
thefont = fontlist.List(i + 1)
‘Selection.TypeText Text:=thefont & vbNewLine
allfonts(i) = thefont
Next i
‘ Delete temp CommandBar if it exists
On Error Resume Next
TempBar.Delete
For y = 1 To UBound(allfonts)
Selection.Font.Name = “Arial”
Selection.TypeText Text:=allfonts(y) & vbNewLine
‘ If youre going to type in Japanese, use this
Application.Keyboard (1041)
Selection.Font.Name = allfonts(y)
Selection.TypeText Text:=”The quick brown fox did his thing”
Selection.EndKey Unit:=wdLine
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
‘Selection.Font.Name = allfonts(y)
‘Selection.TypeParagraph
Selection.EndKey Unit:=wdLine
Selection.TypeText Text:=vbNewLine & vbNewLine
Next y
[/code]
Seems to work pretty well.
[b]Edit:[/b] My real imepetus for doing this was to view all the Japanese fonts that I have installed with something typed in Japanese and styled with the appropriate font. My lovely and smart wife pointed out that you can go to your fonts folder and click on any of the installed fonts to see what the font looks like.