Globally replace the Font on all Access forms.

In Windows 7, the bitmap fonts MS Sans Serif, MS Serif and Courier will not always 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 Access 2010 ClearType is defaulted to ON even if disabled in the OS (RespectSystemFontSmooth)
In Access 2013 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 so good in Office 2013.

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

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 SS64.com 1999-2016
Some rights reserved