How-to: Globally replace the Font on all Access forms.

Problematic fonts in MS Access.

In Windows 7, the bitmap fonts MS Sans Serif, MS Serif and Courier will not resize to match the per-user DPI setting, This is because the size of bitmap fonts is set (and fixed) during setup, which can cause unexpected results.
In Windows 10 the MS Sans Serif font is no longer supplied, if you have existing databases that use the font they will have an automatic fallback but you may prefer to change the font to a known value.

In Access 2010 ClearType is defaulted to ON even if disabled in the OS (RespectSystemFontSmooth)
In Access 2013 and 2016 ClearType is disabled due to incompatibility with tablets (which can be rotated)
This means that fonts from the ClearType font collection (Calibri, Cambria etc) will not look as good in Office 2013 or 2016.

Replace fonts in bulk:

To replace the font used in an existing database, the code below can be used to globally replace it with a suitable True Type font such as Microsoft Sans Serif, Arial or Verdana.

Public Sub UpdateFonts()
On Error Resume Next

' Warning: this will globally change the selected font across all forms in the database.
' It is strongly recommended that you backup the database before running.

Dim dbs As Object
Dim obj As AccessObject
Dim frm As Form
Dim ctl As Control

Set dbs = Application.CurrentProject
' Loop through the AllForms collection.
For Each obj In dbs.AllForms
    DoCmd.OpenForm obj.name, acDesign
    Set frm = Forms(obj.name)

    ' Loop through the controls on each form
    For Each ctl In frm.Controls

        ' Change the Font of text boxes etc
        If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Or ctl.ControlType = acListBox Or ctl.ControlType = acLabel Then
            If ctl.FontName = "MS Sans Serif" Then
                ctl.FontName = "Microsoft Sans Serif"
            End If
        End If
    Next
    
    Set ctl = Nothing

    ' Save the form
    DoCmd.Close acForm, obj.name, acSaveYes

Next obj
End Sub

"Type design is one of the most visible and widespread forms of graphic expression in daily life. It is still not noticed by all readers of newspapers, magazines or books. Nevertheless letter forms reflect the style of a period, and its cultural background. We are surrounded by them everywhere" ~ Hermann Zapf

Related

Q2396756 - Applications using Bitmap Font & DPI
DPI display settings


 
Copyright © 1999-2024 SS64.com
Some rights reserved