Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-16-2013, 11:43 AM
shaukat74 shaukat74 is offline MAcro to List all the Font & its size in a word document Windows 7 64bit MAcro to List all the Font & its size in a word document Office 2010 64bit
Novice
MAcro to List all the Font & its size in a word document
 
Join Date: Jan 2013
Posts: 1
shaukat74 is on a distinguished road
Default MAcro to List all the Font & its size in a word document

I need a Macro to list all the font name & its size in a word file - & list them
This is required as per the Audit by the Project
Can the below Macro be fine tuned for the same. The Below Macro list all the fonts other than arial & give me the page number where the font is located in the 300 page document. I need to modify the macro to give me all the fonts & its size in the new macro
Code:
Sub FindAllFonts()      
    Dim lWhichFont As Long      
    Dim sTempName As String      
    Dim sBuffer As String      
    Dim newDoc As Document Dim p As Long      
    Application.ScreenUpdating = False      
    For lWhichFont = 1 To FontNames.Count          
        sTempName = FontNames(lWhichFont)          
        If sTempName <> "Arial" Then              
            p = FindThisFont(sTempName)              
            If p > 0 Then sBuffer = sBuffer & sTempName & " on page " & p & vbCrLf
        End If 
    End If 
Next lWhichFont 
Set newDoc = Documents.Add  
Selection.TypeText Text:=sBuffer 
Application.ScreenUpdating = True  
End Sub 
 
Function FindThisFont(sName As String) As Long      
    Selection.HomeKey Unit:=wdStory      
    With Selection.Find          
        .Text = ""          
        .ClearFormatting         
        .Font.Name = sName          
        .Forward = True          
        .Format = True 
        If .Execute Then FindThisFont = Selection.Information(wdActiveEndPageNumber)          
    End If      
End With  
End Function


Last edited by macropod; 01-29-2013 at 09:27 PM. Reason: Added code tags & formatting
Reply With Quote
  #2  
Old 01-29-2013, 09:34 PM
macropod's Avatar
macropod macropod is offline MAcro to List all the Font &amp; its size in a word document Windows 7 64bit MAcro to List all the Font &amp; its size in a word document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You can easily enough test for all fonts, including Arial, by deleting the 'If sTempName <> "Arial" Then' test (and its 'End If').

Testing by font size introduces a major overhead, as a font can be anywhere from 1pt to 1638pt, in 0.5pt increments. Testing all (or even a significant range of these) possibilities will slow your code down quite dramatically. Suppose, for example, you only want to test for all sizes from 6pt to 24pt, inclusive. That will make the code take about 37 times longer to run than it now takes.

PS: When posting code, please use the code tags. They're on the 'Go Advanced' tab.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
MAcro to List all the Font &amp; its size in a word document how change size font to inches size kkepo Word 4 08-28-2012 08:53 PM
MAcro to List all the Font &amp; its size in a word document Size of image in Word document no1texan Drawing and Graphics 1 06-29-2012 11:21 PM
Format Font Size in Combo Box List lukewarmbeer Word VBA 0 08-27-2011 07:28 AM
Cursor size varies with font size r_lewis@fuse.net Word 0 07-20-2011 06:11 PM
MAcro to List all the Font &amp; its size in a word document Font list in Word 2007 rahl Word 2 06-26-2011 01:45 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:39 PM.


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