Solved

Change Font's size

Posted on 2011-03-15
4
477 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

710 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