フォントがインストールされているか確認する関数

フォントがインストールされているか確認する関数

 

Option Explicit

 

Function FontCheck(ByVal FontName As String) As String 'フォントがインストールされていなければ標準フォント名を返すユーザー定義関数

 

Dim D As Variant
Dim Count As Long
Dim i As Long
Dim FLG As Integer

 

With Application.CommandBars("Formatting").Controls(1)
    Count = .ListCount
    ReDim D(Count)
    For i = 1 To Count
        D(i - 1) = .List(i)
    Next i
End With

FLG = 0
For i = 1 To Count
    If D(i - 1) = FontName Then
            FLG = 1
            Exit For
    End If
Next i

If FLG = 1 Then
        FontCheck = FontName
    Else
'        FontCheck = "MS Pゴシック"
        FontCheck = Application.StandardFont '標準フォント
End If

 

End Function

 

以上。