Results 1 to 7 of 7
  1. #1
    Lounger
    Join Date
    Oct 2004
    Location
    Indianapolis, Indiana, USA
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Listing used fonts (2000)

    I work for a publishing company. We get electronic text in from authors who use a variety of different word processing programs -- MS Word old and new in both Mac and Windows, OpenOffice, and I think some even send RTF files. We also sometimes deal with older text from books we made years ago, which can present the same problems. Regardless of how the file comes in, we work on it in MS Word 2000.

    The problem is that sometimes fonts appear that aren't installed in our systems -- either the author used a funky font or it appeared when the file changed platforms. I need to be able to make the fonts consistent before I send the files to Layout. I've been looking for and attempting to create a macro that will list all of the fonts that are used in a document, including (and especially) the ones that aren't installed on the system. Here is what I have so far:

    Sub ListFonts()
    Dim dlist As Document
    Dim dsrc As Document
    Dim sfnt As String
    Dim rchar As Range

    Set dsrc = ActiveDocument
    Documents.Add
    Set dlist = ActiveDocument
    Selection.Find.ClearFormatting

    For Each rchar In dsrc.Characters
    sfnt = rchar.Font.Name
    dlist.Range(0, 0).Select
    With Selection.Find
    .Text = sfnt
    .Format = False
    .Wrap = wdFindStop
    End With
    Selection.Find.Execute
    If Not Selection.Find.Found Then
    dlist.Range.Select
    Selection.Collapse (wdCollapseEnd)
    Selection.TypeText (sfnt & vbCr)
    End If
    Next rchar

    End Sub

    This essentially pastes a font name to a new document, then checks the original document character by character, comparing the font names there with what has been pasted to the new document, adding any new names that didn't originally appear. This is a brute-force type of macro that obviously takes a while to run. Does anyone know of another macro that is more streamlined? Or can anyone find a way to streamline this code? (I originally searched word for word, instead of character by character, but it missed fonts that were applied to only one character in a word.)

    Thanks.
    Andy

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Listing used fonts (2000)

    It might be a little quicker to get all the fonts from Application.Fontnames and then use ActiveDocument.Content.Find to search for each one in turn.

    Something a bit like...
    <code>
    Public Sub FindFontsInUse()
    Dim strFont As Variant

    For Each strFont In Application.FontNames
    With ActiveDocument.Content.Find
    .ClearFormatting
    .Text = "^?"
    .Font.Name = strFont
    If .Execute Then
    Debug.Print strFont
    End If
    End With
    Next strFont

    End Sub
    </code>

    (This only checks the main story, you would have to loop through all StoryRanges if you want to check text boxes, comments, headers etc.

    StuartR

  3. #3
    Lounger
    Join Date
    Oct 2004
    Location
    Indianapolis, Indiana, USA
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Listing used fonts (2000)

    I've seen something similar to this before, though your version is by far the most succinct.
    The problem with this code is that searching through Application.FontNames searches only through the fonts that are installed on the system. It won't find the fonts that were used in the original file that aren't installed on my system.

    Andy

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Listing used fonts (2000)

    Have a look at this thread. While it refers to Word 2003, the solutions discussed there may work for you: Listing fonts in document (2003).

  5. #5
    3 Star Lounger
    Join Date
    Apr 2004
    Location
    Boston, Massachusetts, USA
    Posts
    389
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Listing used fonts (2000)

    Adding Phil Rabichow's line of code from <post#=419266>post 419266</post#> to the macro I posted in <post#=383215>post 383215</post#> should do the trick. If the document is *really* long, and that macro is too slow, I've got some techniques for optimizing that sort of character iteration.

  6. #6
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    120
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Listing used fonts (2000)

    Do you really need a macro to find the fonts used in the doc but not installed on your system? Under Tools-Options-Compatibility in WordXP there is a "font substitution" button that lists document fonts that are not installed together with the font that will be substituted - I don't recall whether Word 2k has the same button but I'm guessing it does. Maybe not as convenient as an automated solution but certainly quick!!

  7. #7
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Listing used fonts (2000)

    It's there in Word 2000, too. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •