R
Russ
Y'all: I took some code posted here few years back and expanded it so
that I can highlight the characters in my Word document that are of
undesireable font type. This works but is SLOW. How can I determine
all font types used in a Word document without going through each
character?
russ
Public Sub BSLFontMark()
'Macro created by rwpatter
' Characters with incompatible font are highlighted in yellow.
Dim GoodFontList(39) As String
Dim FontName As String
Dim BSL_OK As Boolean
Dim NoBadFontFound As Boolean
Dim i As Integer
Dim V As Long, Y As Long, X As Long, Z As Long
Dim rngChar As Range
NoBadFontFound = True
'list of fonts that are allowed in BSL database
GoodFontList(1) = "Arial"
GoodFontList(2) = "Arial Black"
GoodFontList(3) = "Arial Narrow"
GoodFontList(4) = "Book Antiqua"
GoodFontList(5) = "Bookman Old Style"
GoodFontList(6) = "Century Gothic"
GoodFontList(7) = "Comic Sans MS"
GoodFontList(8) = "Courier New"
GoodFontList(9) = "Estrangelo Edessa"
GoodFontList(10) = "Franklin Gothic Medium"
GoodFontList(11) = "Garamond"
GoodFontList(12) = "Gautami"
GoodFontList(13) = "Georgia"
GoodFontList(14) = "Haettenschweiler"
GoodFontList(15) = "Impact"
GoodFontList(16) = "Latha"
GoodFontList(17) = "Lucida Console"
GoodFontList(18) = "Lucida Sans Unicode"
GoodFontList(19) = "Mangal"
GoodFontList(20) = "Math Ext"
GoodFontList(21) = "Monotype Corsiva"
GoodFontList(22) = "MS Outlook"
GoodFontList(23) = "MT Extra"
GoodFontList(24) = "Mv Boli"
GoodFontList(25) = "Platino Linotype"
GoodFontList(26) = "Raavi"
GoodFontList(27) = "Shruti"
GoodFontList(28) = "Sylfaen"
GoodFontList(29) = "Symbol"
GoodFontList(30) = "Tahoma"
GoodFontList(31) = "Times New Roman"
GoodFontList(32) = "Trebuchet MS"
GoodFontList(33) = "Trebuchet MS"
GoodFontList(34) = "Tunga"
GoodFontList(35) = "Verdana"
GoodFontList(36) = "Webdings"
GoodFontList(37) = "WingDings"
GoodFontList(38) = "Wingdings 2"
GoodFontList(39) = "Wingdings 3"
Y = 0
Z = 0
X = ActiveDocument.Characters.Count
' For-Next loop through every character
For Each rngChar In ActiveDocument.Characters
Y = Y + 1
FontName = rngChar.Font.Name
i = 1
BSL_OK = False
Do Until i = 40
If GoodFontList(i) = FontName Then
BSL_OK = True 'font is a BSL good font
End If
i = i + 1
Loop
If Not BSL_OK And FontName <> "" Then 'Fontname ""
rngChar.HighlightColorIndex = wdYellow
Z = Y 'marks last place a bad font found
V = V + 1 'keeps up with count of bad font chars found
NoBadFontFound = False
End If
StatusBar = Format((Y / X), "0%") 'display status in %
Next rngChar
Selection.SetRange Start:=Z, End:=Z
If NoBadFontFound Then
MsgBox "Congratulations, No BSL incompatible fonts found, document OK
for BSL entry."
Else
MsgBox V & " BSL font incompatible characters found!" & vbCrLf & vbCrLf
& "The text I have highlighted in Yellow is incompatible with the BSL.
Change font type."
End If
End Sub
that I can highlight the characters in my Word document that are of
undesireable font type. This works but is SLOW. How can I determine
all font types used in a Word document without going through each
character?
russ
Public Sub BSLFontMark()
'Macro created by rwpatter
' Characters with incompatible font are highlighted in yellow.
Dim GoodFontList(39) As String
Dim FontName As String
Dim BSL_OK As Boolean
Dim NoBadFontFound As Boolean
Dim i As Integer
Dim V As Long, Y As Long, X As Long, Z As Long
Dim rngChar As Range
NoBadFontFound = True
'list of fonts that are allowed in BSL database
GoodFontList(1) = "Arial"
GoodFontList(2) = "Arial Black"
GoodFontList(3) = "Arial Narrow"
GoodFontList(4) = "Book Antiqua"
GoodFontList(5) = "Bookman Old Style"
GoodFontList(6) = "Century Gothic"
GoodFontList(7) = "Comic Sans MS"
GoodFontList(8) = "Courier New"
GoodFontList(9) = "Estrangelo Edessa"
GoodFontList(10) = "Franklin Gothic Medium"
GoodFontList(11) = "Garamond"
GoodFontList(12) = "Gautami"
GoodFontList(13) = "Georgia"
GoodFontList(14) = "Haettenschweiler"
GoodFontList(15) = "Impact"
GoodFontList(16) = "Latha"
GoodFontList(17) = "Lucida Console"
GoodFontList(18) = "Lucida Sans Unicode"
GoodFontList(19) = "Mangal"
GoodFontList(20) = "Math Ext"
GoodFontList(21) = "Monotype Corsiva"
GoodFontList(22) = "MS Outlook"
GoodFontList(23) = "MT Extra"
GoodFontList(24) = "Mv Boli"
GoodFontList(25) = "Platino Linotype"
GoodFontList(26) = "Raavi"
GoodFontList(27) = "Shruti"
GoodFontList(28) = "Sylfaen"
GoodFontList(29) = "Symbol"
GoodFontList(30) = "Tahoma"
GoodFontList(31) = "Times New Roman"
GoodFontList(32) = "Trebuchet MS"
GoodFontList(33) = "Trebuchet MS"
GoodFontList(34) = "Tunga"
GoodFontList(35) = "Verdana"
GoodFontList(36) = "Webdings"
GoodFontList(37) = "WingDings"
GoodFontList(38) = "Wingdings 2"
GoodFontList(39) = "Wingdings 3"
Y = 0
Z = 0
X = ActiveDocument.Characters.Count
' For-Next loop through every character
For Each rngChar In ActiveDocument.Characters
Y = Y + 1
FontName = rngChar.Font.Name
i = 1
BSL_OK = False
Do Until i = 40
If GoodFontList(i) = FontName Then
BSL_OK = True 'font is a BSL good font
End If
i = i + 1
Loop
If Not BSL_OK And FontName <> "" Then 'Fontname ""
rngChar.HighlightColorIndex = wdYellow
Z = Y 'marks last place a bad font found
V = V + 1 'keeps up with count of bad font chars found
NoBadFontFound = False
End If
StatusBar = Format((Y / X), "0%") 'display status in %
Next rngChar
Selection.SetRange Start:=Z, End:=Z
If NoBadFontFound Then
MsgBox "Congratulations, No BSL incompatible fonts found, document OK
for BSL entry."
Else
MsgBox V & " BSL font incompatible characters found!" & vbCrLf & vbCrLf
& "The text I have highlighted in Yellow is incompatible with the BSL.
Change font type."
End If
End Sub