Populate combo box with names of installed fonts

TimTDP

Registered User.
Local time
Today, 19:22
Joined
Oct 24, 2008
Messages
213
I need to give users the ability to change the font of a field in a report. The field shows a barcode.

I thought of using the CommonDlg class to show the Windows font-selecting dialog box, but installed barcode fonts show as a barcode. I need to show the font name.

So I need to populate a combo box with the names of all fonts installed on a computer.
The fonts reside in C:\windows\fonts

I have searched Google for a solution but cannot find one.

How do I populate a combo box with the names of all fonts installed on a computer?

Thanks in advance
 
Use the Dir function and store the returned value in a table or directly in the combo box "Row Source"

Code:
    Dim FileName As String
    'Remember to insert the fonts file extension instead of the star.
    FileName = Dir("C:\windows\fonts\*.[COLOR=Red][B]*[/B][/COLOR]")
    Do While FileName <> ""
      'Here insert your code for storing the return value, just now it is printed to the Immediate window.  
      Debug.Print FileName
      FileName = Dir()
    Loop
 
I tried this but it returns:
ArialBd.ttf for Arial Bold
Arialbi.ttf for Arial Bold Italic

Not very helpful to the user
 
I use a font picker based on this function. However, I don't have a bar code font installed to see how the picker displays the font.

Private Declare Function ChooseFont Lib "comdlg32.dll" Alias "ChooseFontA" _
(pChoosefont As FONTSTRUC) As Long
 
The font names are stored in the Registry under
HKLM\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Fonts

Read the subkeys and construct the listbox recordset accordingly.
 

Users who are viewing this thread

Back
Top Bottom