获取VBA Excel 2010中所有字体的列表 [英] Get a list of all fonts in VBA Excel 2010

查看:55
本文介绍了获取VBA Excel 2010中所有字体的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在excel VBA中工作,我想在组合框中获取所有字体的列表

I am working in excel VBA and I want to get the list of all fonts in a combo box

任何人都可以帮我吗

我尝试了此代码,但listcount出现错误:

I tried this code but i am getting error in 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

推荐答案

从字体中获取字体列表的另一种方法

Another way to get the list of fonts (from Word)

Option Explicit

Sub listFonts()
    Dim wd As Object, fontID As Variant

    Set wd = CreateObject("Word.Application")

    For Each fontID In wd.FontNames
        Sheet1.cmbFonts.AddItem fontID
    Next
    wd.Quit
    Set wd = Nothing
End Sub

这篇关于获取VBA Excel 2010中所有字体的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆