I tried to create a macro to identify list of font types in a document. While searching this topic on Google, I got found a similar macro to do this thing and I have customized that macro for my work. But the concern is this macro takes too much time to complete the process (< 20min for some documents).
Code: Select all
Sub FindFontTypes()
Dim StrFntArr As String
StrFntArr = GetFonts(ActiveDocument)
MsgBox "The following font colors are used in this document:" & vbNewLine & StrFntArr
End Sub
Private Function GetFonts(ByVal oDocument As Document) As String
Dim oParagraph As Paragraph
Dim i As Integer
Dim oWord As Words
Dim sFontType As String
Dim StrFntArr As String
For Each oParagraph In oDocument.Paragraphs
For i = 1 To oParagraph.Range.Characters.Count
sFontType = oParagraph.Range.Characters(i).Font.Name
If InStr(1, StrFntArr, sFontType) = 0 Then
StrFntArr = StrFntArr & sFontType & vbNewLine
End If
Next
Next
GetFonts = StrFntArr
End Function
1. Find first character font type.
2. Record the font type as string.
3. Hide all characters in that font. (loop 1,2,3 steps)
4. If all characters got hide then display font type as a massage box.
Appreciate your help to develop this macro. Thank you!