What is the easiest way to check if a particular font is installed using VBA?
相关问题
- Error handling only works once
- Excel formula in VBA code
- how to Enumerate local fonts in silverlight 4
- Excel VBA run time error 450 from referencing a ra
- DoCmd.TransferSpreadsheet is not recognizing works
相关文章
- Unregister a XLL in Excel (VBA)
- numeric up down control in vba
- Loading custom font using JavaFX 8 and css
- Generating .afm from .ttf [closed]
- Declare a Range relative to the Active Cell with V
- Vue Cli 3 Local fonts not loading
- How to disable changes in a cell using vba?
- MsgBox Yes/No Excel VBA
OK, true to form I found a solution 30 seconds after posting this. This is despite a 10 minute search before resorting to SO....
List installed fonts
The procedure listed below displays a list of installed fonts in Column A of the active worksheet. It uses the
FindControl
method to locate the Font control on the Formatting toolbar. If this control is not found (i.e. it was removed by the user) a temporary CommandBar is created and the Font control is added to it.Is a font installed?
The function below uses the same technique as the ShowInstalledFonts procedure. It returns True if a specified font is installed.
The statement below demonstrates how to use this function in a VBA procedure. It displays True in a message box if the user's system contains the Comic Sans MS font.
The above was originally at this URL, retrieved from the Internet Archive on 2020-02-05.
http://www.vbcity.com/forums/topic.asp?tid=57012
redirects to
http://vbcity.com/forums/t/55257.aspx
This vb6 code is compatible with VBA:
using apis there are
EnumFonts The EnumFonts function enumerates the fonts available on a specified device. For each font with the specified typeface name, the EnumFonts function retrieves information about that font and passes it to the application-defined callback function. This callback function can process the font information as desired. Enumeration continues until there are no more fonts or the callback function returns zero.
VB4-32,5,6
or
The EnumFontFamilies function enumerates the fonts in a specified font family that are available on a specified device. This function supersedes the EnumFonts function.
VB4-32,5,6
example routine