View Single Post
 
Old 10-31-2021, 05:54 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
Default

Firstly, huge apologies to Andrew and Paul for not thanking them for the replies. Work got the better of me and I missed the reply notifications. The above is useful, many thanks.

I'd like to take it a step further for another area of the VBA. To illustrate, please see the adapted code below with commenting.

Quote:
Sub FontCheckAndSubstitute()
'
' Check for "Blobby" font and apply it to "Normal" style.
' If "Blobby" font is not installed, substitute with something from a set list of alternatives.
' If alternatives are not installed, let Word substitute with nearest common font
'
Dim lFound As Boolean
Dim font As Variant

font = "Blobby"
Let lFound = False

' Check for "Blobby" font

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

Next aFont

' If "Blobby" font isn't installed...

If lFound = False Then
Call MsgBox("For best results, please install the font '" & font & "'. Word will substitute with the closest match." & vbCrLf & vbCrLf & _
"Pres OK to continue.", vbOKOnly + vbExclamation, "Required Font Missing")

' Need help here:

' Substitute "Blobby" with a font from a list of alternatives (e.g. "Jelly", "Spongey", "Bouncey")
' Or let Word substitute with a common font if alternatives are not installed (e.g. "Courier New")

End If


' Apply "Blobby" or substituted font to Normal style

With ActiveDocument.Styles("Normal").font
.Name = font '<------ Is this correct?
.Size = 12
End With

End Sub
Thanks, folks.
Reply With Quote