I am working in excel VBA and I want to get the list of all fonts in a combo box
Can any one help me please
I tried this code but i am getting error in listcount
The FontList
should be returning a list that is indexed as 1 based. There is no need to start at 0.
Dim FontList
Dim i As Long
Set FontList = Application.CommandBars("Formatting").FindControl(ID:=1728)
'Put the fonts into column A
For i = 1 To FontList.ListCount
Debug.Print FontList.List(i)
Cells(Rows.Count, 1).End(xlUp)(2) = FontList.List(i)
'combobox.AddItems FontList.List(i)
If i > 50 Then Exit For
Next i
That should build a list of fonts into column A of the ActiveSheet. When that is working, remove the commenting so that it goes into your combobox.
Note that you will be getting a list of fonts that exactly duplicates the font list dropdown on the Home ribbon. There will likely ba a few duplicates as that list duplicates a couple of fonts at the top of the list for the default Heading and Body categories.