First Published 4 Feb 2025 Last Updated 10 Feb 2025
The attached DialogFont function code is used to display a standard Windows font dialog for use in any Access application:
I should stress that the code is not mine. It is based on old code for 32-bit Access by Stephen Lebans and Terry Kreft at https://lebans.com/fontcolordialog.htm and since updated to be 64-bit compatible by Philipp Stiefel at ChooseFont-Dialog-API for 64-Bit-VBA
A helper function: testDialogFont makes this code easy to use.
Add a command button cmdFont and a textbox Text0 to a form.
Now add the following code to the button click event:
Private Sub cmdFont_Click()
'apply the selected font style to the textbox
testDialogFont Me.Text0
End Sub
Clicking the button opens the font dialog and the selected font is used on the textbox. For example:
NOTE:
The Strikethrough/Strikeout property is NOT supported in Access and is ignored here. If you require strikethrough text, use a special font: Strikethrough Font in Access
Alternative Approaches
Over the years, I have tried various other approaches to get font lists using file properties and registry information.
Windows font files are stored in the C:\Windows\Fonts folder:
If you just want to select from a list of True Type fonts, this can easily be obtained by looping through the C:\Windows\Fonts folder, filtering for *.ttf files, and adding these to a combo or listbox.
Unfortunately, this is of limited value as it just returns the file name (without the .ttf suffix).
The name associated with each font is actually the Title property.
For most Windows files, this would be easily obtained using an approach similar to that in my Get Extended Properties article.
However, the C:\Windows\Fonts folder is protected and prevents that code working correctly. Easily done on a copy of the font!
To obtain that information for all fonts would require first copying the entire contents of the Fonts folder to an unprotected folder. Definitely a step too far!
Another approach is to extract the font information from the registry: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts
This takes a couple of seconds to complete but gives more useful output. Compare the two methods below:
Registry Fonts
![]() |
Windows Font Folder
![]() |
The font names can be used to populate the combo box / listbox row source as a value list or saved to a table.
The latter method is preferred as the form will load instantly. Also you can filter the font list to remove variants of the same font such the 10 Arial fonts seen in the list above.
I use this approach in my example app used to demonstrate modifying various modern chart properties in code at runtime. See my article:
Use VBA Code to set Chart Properties
In that app, I have a combo with a filtered font list obtained from the registry and used to set the font name used in the chart title:
It will depend on the situation as to whether the font dialog approach or a saved list of fonts is more suitable for your purposes.
Download
The example app includes the code used for each method described in this article.
Click to download:
Font Dialog Code v1.1 (ACCDB - zipped)
All items are available from a startup form. The list of fonts is saved to the table tblFonts using an autoexec macro when the app is first loaded.
NOTE:
The new default Office font, Aptos, is not listed in any of the methods used in this example app. It also does not appear in built-in Access dropdowns in the property sheet.
This is because it is not located in the standard Windows font folder nor the standard registry location. I asked CoPilot for information, but got no answer at all!
NOTE:
After publishing this article, I used the wonderful
Everything app to search for the Aptos font.
As shown above, Aptos is one of many fonts located in a separate CloudFonts folder:C:\Users\UserName\AppData\Local\Microsoft\FontCache\4\CloudFonts
There are 88 of these fonts on my workstation, none of which appear in the property sheet UNLESS they are used in an Access theme.
The Aptos folder contains 10 variants of the Aptos font, each of which can be installed in the usual way
This copies the font to the standard C:\Windows\Fonts folder. After doing so, the installed font does appear in the property sheet as for any other installed font.
However, it does not get added to the default registry fonts folder: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts
As a result, it is still not shown in the list of fonts detected by my code based on registry entries.
Feedback
Please use the contact form below to let me know whether you found this article interesting/useful or if you have any questions/comments.
Please also consider making a donation towards the costs of maintaining this website. Thank you
Colin Riddington Mendip Data Systems Last Updated 10 Feb 2025
Return to Code Samples Page
|
Return to Top
|