我正在使用 Excel VBA,我想获取组合框中所有字体的列表
任何人都可以帮助我吗
我尝试了这段代码,但在 listcount 中出现错误:
...
Set FontList = Application.CommandBars("Formatting").FindControl(ID:=1728)
' Put the fonts into column A
*For i = 0 To FontList.ListCount - 1*
combobox.AddItems FontList.List(i + 1)
Next i
' Delete temp CommandBar if it exists
On Error Resume Next
TempBar.Delete
End Sub
The FontList
应该返回一个索引为 1 的列表。没必要从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
这应该在 A 列中构建一个字体列表活动表。当它起作用时,删除注释,以便它进入您的组合框。
请注意,您将获得与主页功能区上的字体列表下拉列表完全相同的字体列表。可能会有一些重复项,因为该列表重复了默认标题和正文类别列表顶部的几种字体。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)