Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    May 2001
    Location
    Cheshire, England
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Search for Fonts (9.0 sr-1)

    I want to be able to search through a document and find any text which has a font which is not Times New Roman.
    I need to be able to do this with VBA. Anyone got any ideas?

  2. #2
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Search for Fonts (9.0 sr-1)

    Jayce, I cannot see of a way to get the Find object to find something not in a list, but I just used brute force:<pre>Option Explicit
    Sub Macro1()
    Dim c As Range
    For Each c In ActiveDocument.Characters
    If c.Font.Name <> "Times New Roman" Then
    c.Font.Name = "Times New Roman"
    End If
    Next c
    End Sub</pre>

    This changes everything to Times New Roman, but you could substitute c.select, Exit Sub instead, if you needed manual intervention. It's not fast, but tolerable for medium-sized documents. Hope this helps! --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  3. #3
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Search for Fonts (9.0 sr-1)

    Hi Jayce,
    another way to skin the cat <img src=/S/catty.gif border=0 alt=catty width=19 height=18> the following macro selects the next passage of text formatted in another font than Times New Roman:

    <pre>Sub MoveToNextFont()
    Selection.Collapse Direction:=wdCollapseEnd
    Selection.SelectCurrentFont
    While Selection.Font.Name = "Times New Roman"
    Selection.Collapse Direction:=wdCollapseEnd
    Selection.SelectCurrentFont
    Wend
    End Sub</pre>


    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>Klaus

  4. #4
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Search for Fonts (9.0 sr-1)

    Talking of brute force, surely the easiest way to do it would just be Ctrl-A (select all) and change the font to TimesNewRoman?
    Beryl M


  5. #5
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Search for Fonts (9.0 sr-1)

    Klaus, Thanks for the wonderful tip, I had never seen the SelectCurrentFont method before. Plus, there are a bunch of other SelectCurrent... methods. With a couple of mods, I've got a wonderful Find tool! --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  6. #6
    New Lounger
    Join Date
    May 2001
    Location
    Cheshire, England
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Search for Fonts (9.0 sr-1)

    Many thanks Klaus, this is just what I needed to do the font check. <img src=/S/cool.gif border=0 alt=cool 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
  •