Option Explicit
Private Const HWND_BROADCAST As Long = &HFFFF&
Private Const WM_FONTCHANGE As Long = &H1D
Private Declare Function PathFileExists Lib "shlwapi.dll" Alias "PathFileExistsA" (ByVal pszPath As String) As Long
Private Declare Function AddFontResource Lib "gdi32.dll" Alias "AddFontResourceA" (ByVal lpFileName As String) As Long
Private Declare Function RemoveFontResource Lib "gdi32.dll" Alias "RemoveFontResourceA" (ByVal lpFileName As String) As Long
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) As Long
Private fontPath As String
Private Sub Form_Initialize()
fontPath = App.Path & IIf(Right(App.Path, 1) = "\", "", "\") & "sample.ttf"
If PathFileExists(fontPath) = 0 Then
MsgBox "This font not found :" & vbNewLine & fontPath
Else
AddFontResource fontPath
SendMessage HWND_BROADCAST, WM_FONTCHANGE, 0, ByVal 0&
End If
End Sub