Solved

Change Font's size

Posted on 2011-03-15
4
476 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

820 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