Results 1 to 3 of 3
  1. #1
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Font list in combo (2000 VBA)

    I'm needing to display the standard dropdown list of available fonts, within a userform. The user selection will then be used to modify the font face of an existing style. Is there a simple way to "build" such a combobox in VBA? I've seen some code using various API functions, but was hoping for something quick & easy.

    Alan

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Font list in combo (2000 VBA)

    You don't specify in hich Office app you want to use this.

    Word has a FontNames object:

    Private Sub UserForm_Initialize()
    Dim i As Long
    For i = 1 To FontNames.Count
    cbxFonts.AddItem FontNames(i)
    Next i
    End Sub

    John Walkenbach has a tip for Excel, but I can't get it to work, maybe you have better luck.

  3. #3
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Font list in combo (2000 VBA)

    Sorry, I didn't think that this might vary between Office apps. Unfortunately it's Excel I'm looking at <img src=/S/disappointed.gif border=0 alt=disappointed width=15 height=15>. I'll have a look at the link you provided, thanks... one more "challenge" to add to the week's quota <img src=/S/grin.gif border=0 alt=grin width=15 height=15>. I also found some code for VB, which I couldn't get to work - it used API functions to fill the combobox and these require a handle to the combobox, which I would have no idea about in the VBA context.

    thanks for your help, as always

    Alan

    Edited - Hans, the ShowInstalledFonts() code you provided the link to seemed to work properly for me "straight out of the box". I didn't try to seed a combobox, but it filled col A of the spreadsheet, as advertised.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •