Solved

Change Font's size

Posted on 2011-03-15
4
473 Views
Last Modified: 2012-05-11
Hi, in my word file, I want to change all the words which have font size less than or equal 6 to 10. Need macro code(VBA).

Thanks,
0
Comment
Question by:zhshqzyc
  • 2
4 Comments
 
LVL 1

Expert Comment

by:nickthename
ID: 35139057

Sub ChangeSize()

ChangeFontFromTo 6, 10

End Sub

Sub ChangeFontFromTo(InitialFontSize As Integer, FinalFontSize As Integer)
Dim iCharacters As Integer

    For iCharacters = 1 To ActiveDocument.Characters.Count
        If ActiveDocument.Characters(iCharacters).Font.Size = InitialFontSize Then ActiveDocument.Characters(iCharacters).Font.Size = FinalFontSize
    Next
End Sub
0
 
LVL 1

Expert Comment

by:nickthename
ID: 35139069
Sorry I didn't see  less or equal:

Sub ChangeSize()

ChangeFontFromTo 6, 10

End Sub

Sub ChangeFontFromTo(InitialFontSize As Integer, FinalFontSize As Integer)
Dim iCharacters As Integer

    For iCharacters = 1 To ActiveDocument.Characters.Count
        If ActiveDocument.Characters(iCharacters).Font.Size <= InitialFontSize Then ActiveDocument.Characters(iCharacters).Font.Size = FinalFontSize
    Next
End Sub
0
 

Author Comment

by:zhshqzyc
ID: 35139166
Thanks. But I got an error: "Overflow".
0
 
LVL 22

Accepted Solution

by:
Paka earned 125 total points
ID: 35139353
Sub replaceFont6()
    Selection.Find.ClearFormatting
    Selection.Find.Font.Size = 6
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Size = 12
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now