Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Spurious Change of Fonts

Status
Not open for further replies.

TrekBiker

Technical User
Nov 26, 2010
330
GB

A client has reported that font names throughout their database have recently been automatically changed, same for all users' copies. The change is from Calibri 10 to MS Sans Serif 10, for most but not for all controls on the forms. There's some dialogue on the web about an Office 365 upgrade being responsible.

Manually changing fonts would be a very big task but I found this code which looked to give a solution for selected control types. I think I've used it successfully years ago but it doesn't seem to work on the current database.

Code:
Private Sub cmdChangeFont_Click()

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)
    Debug.Print obj.Name
    ' Loop through the controls on each form
    For Each ctl In frm.Controls
    Debug.Print ctl.Name

        ' 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 = "Verdana" Or ctl.FontName = "MS Sans Serif" Then
                ctl.FontName = "Calibri"
            End If
        End If
    Next
    
    Set ctl = Nothing

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

Next obj

End Sub

 

Thanks Duane, spot on. They say there's a fix on the way, so no need to do antything meantime.

Hope your recovery is progressing well, and you're back on the bike.
 
Hi TrekBiker,
Rehab is going well. It’s been 4 months since the “widow maker” and I’ve riding indoors and out. I’ve a ways to go to gain back the endurance.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top