Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Change Font's size

Posted on 2011-03-15
4
Medium Priority
?
485 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 500 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

972 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