View Single Post
 
Old 06-06-2021, 05:28 AM
Matt C's Avatar
Matt C Matt C is offline Windows 10 Office 97-2003
Advanced Beginner
 
Join Date: May 2021
Location: London, UK
Posts: 30
Matt C is on a distinguished road
Question Check the font attached to a template's "Normal" style and report if it's not installed

Hi folks.

I found this useful code on Adam Dimech's Coding Blog which checks to see if the User has the required template font installed on their computer and reports with a Message Box.

However, I'd like VBA to check for whatever font has been set in the "Normal" style when creating a new, or opening an existing, document based on the template, rather than specifying a font name in the code.

Quote:
Sub FontCheck()
'
' With thanks to Adam Dimech's Coding Blog (Adam Dimech's Coding Blog)
'
Dim lFound As Boolean
Dim font As Variant

font = "Courier Final Draft" 'This is where I'd like it to check the "Normal" style font
Let lFound = False

For Each aFont In Application.FontNames
If aFont = font Then
Let lFound = True
End If

Next aFont

If lFound = False Then
Call MsgBox("Please install the font '" & font & "' before using this template.", vbExclamation, "Required font missing")
End If
End Sub
Thanks in advance, folks.
Reply With Quote