Adding font name

L

Lee

Hi All
I have the following code which types "ABCD..." in each font type that you
have on your PC. I want to also add each font name to the generated document
next to each the corresponding line of text in that font, e.g.
ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 123456789 - Arial

Sub listfonts()

Documents.Add

For Each thisfont In FontNames

With Selection
.InsertAfter "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
123456789" & vbCr
.MoveUp unit:=wdParagraph, Count:=1
.MoveDown unit:=wdParagraph, Count:=1, Extend:=wdExtend
.Font.Name = thisfont
.Font.Size = 10
.MoveDown unit:=wdParagraph, Count:=2
End With
Next
End Sub

Any help would be appreciated. Thanks
 
H

Helmut Weber

Hi Lee,

how about this one:

Dim sFnt As Variant
Dim sExm As String
Dim lPrg As Long
'sExm = "ABCDEFGHIJKLMNOPQRSTUVWXYZ "
sExm = "abcdefghijklmnopqrstuvwxyz - "
'sExm = sExm & "123456789 - "
With ActiveDocument
.Range.Delete
For Each sFnt In FontNames
.Range.InsertAfter sExm & sFnt & vbCr
lPrg = .Paragraphs.count
.Range.Paragraphs(lPrg - 1).Range.Font.Name = sFnt
Next
End With

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top