locked
Populate combo box with names of installed fonts RRS feed

  • Question

  • 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 tried:

    Dim FileName As String
        'Remember to insert the fonts file extension instead of the star.
        FileName = Dir("C:\windows\fonts\*.*")
        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


    but it returns:
    ArialBd.ttf for Arial Bold
    Arialbi.ttf for Arial Bold Italic

    Not very helpful to the user!

    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


    Thursday, January 23, 2014 2:49 PM

All replies

  • Hi TimTDP2,

    Thank you for posting in the MSDN Forum.
    Since the issue is more relate to Visual Bsic for Application, I'd like to move it to Visual Bsic for Application forum.

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.

    Thanks for your understanding.

    Best regards
    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, January 24, 2014 5:13 AM
  • Use these codes :

    For Each FF As FontFamily In FontFamily.Families
        ComboBox1.Items.Add(FF.Name)
    Next

    Friday, January 24, 2014 1:31 PM