Solved

Change Font's size

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Nice table. Huge mess. Maybe this was something you created way back before you figured out tabs or a document you received from someone else. Either way, using the spacebar to separate the columns resulted in a mess. Trying to convert text to t…
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…
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…

746 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