增加临时使用的字体,代码如下:
Option Compare Database
Option Explicit
Private Declare Function AddFontResource _
Lib "gdi32" Alias "AddFontResourceA" _
(ByVal lpFileName As String) As Long
Private Declare Function RemoveFontResource _
Lib "gdi32" Alias "RemoveFontResourceA" _
(ByVal lpFileName As String) As Long
Public Function AddFont(ByVal FontPath As String) As Boolean '增加字体
AddFont = AddFontResource(FontPath) = 1
End Function
Public Function RemoveFont(ByVal FontPath As String) As Boolean '删除字体
RemoveFont = RemoveFontResource(FontPath) = 1
End Function
*********************************************************************
也许在你的应用程序中要临时使用某种字体,以增强程序表现力。
举例:
增加“天气”字体
Debug.Print AddFont(CurrentProject.Path & "\Fonts\tianqi.TTF")
删除“天气”字体
Debug.Print RemoveFont(CurrentProject.Path & "\Fonts\tianqi.TTF")