Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 05-09-2018, 01:00 PM
David Matthews David Matthews is offline Macro for Font Names and Sizes Windows 7 64bit Macro for Font Names and Sizes Office 2016
Novice
 
Join Date: May 2018
Posts: 6
David Matthews is on a distinguished road
Default

This gives a list of all fonts used, but not the sizes (oh, it takes a while to run, BTW):

Public Sub ListFontsInDoc1()
Dim FontList(199) As String
Dim FontCount As Integer
Dim FontName As String
Dim J As Integer, K As Integer, L As Integer
Dim X As Long, Y As Long
Dim FoundFont As Boolean
Dim rngChar As Range
Dim strFontList As String

FontCount = 0
X = ActiveDocument.Characters.Count
Y = 0
' For-Next loop through every character
For Each rngChar In ActiveDocument.Characters
Y = Y + 1
FontName = rngChar.Font.Name
StatusBar = Y & ":" & X
' check if font used for this char already in list
FoundFont = False
For J = 1 To FontCount
If FontList(J) = FontName Then FoundFont = True
Next J
If Not FoundFont Then
FontCount = FontCount + 1
FontList(FontCount) = FontName
End If
Next rngChar

' sort the list
StatusBar = "Sorting Font List"
For J = 1 To FontCount - 1
L = J
For K = J + 1 To FontCount
If FontList(L) > FontList(K) Then L = K
Next K
If J <> L Then
FontName = FontList(J)
FontList(J) = FontList(L)
FontList(L) = FontName
End If
Next J

StatusBar = ""
' put in new document
Documents.Add
Selection.TypeText Text:="There are " & _
FontCount & " fonts used in the document, as follows:"
Selection.TypeParagraph
Selection.TypeParagraph
For J = 1 To FontCount
Selection.TypeText Text:=FontList(J)
Selection.TypeParagraph
Next J
End Sub
Reply With Quote
 

Tags
macro vba word



Similar Threads
Thread Thread Starter Forum Replies Last Post
Same selection of font..different sizes... Garyz Word 8 02-02-2016 09:13 AM
Change font sizes in template Calab PowerPoint 1 12-23-2013 09:29 AM
Reply: huge font sizes... Uli Outlook 3 09-19-2012 06:57 PM
Font sizes in Outlook 2003 peterandrew Outlook 3 09-18-2012 04:26 AM
Changing all different font sizes by a value Puffin617 Word VBA 6 05-21-2009 08:23 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:44 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft