office交流网--QQ交流群号

Access培训群:792054000         Excel免费交流群群:686050929          Outlook交流群:221378704    

Word交流群:218156588             PPT交流群:324131555

Excel提取系统安装的字体列表

2021-01-15 08:00:00
tmtony8
原创
3045

在创建的应用程序中, 我们输入信息可以用文本框,但是文本框是单纯的文本文字,没有其他格式

可以用富文本控件,富文本编辑器是带有格式的。

我们也可以调用系统的文字格式。下面的代码,可以获取系统安装的字体名称。


Sub ShowInstalledFonts()
    Dim FontList As CommandBarControl
    Dim TempBar As CommandBar
    Dim i As Long
    

    Set TempBar = Application.CommandBars.Add
    Set FontList = TempBar.Controls.Add(ID:=1728)
    

    Range("A:A").ClearContents     '字体逐个添加到A列中
    For i = 0 To FontList.ListCount - 1
        Cells(i + 1, 1) = FontList.List(i + 1) 
    Next i
    
  
    TempBar.Delete   '清空内容
End Sub



点击按钮,字体名称添加到A列中,该按钮代码如上

    分享