Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-20-2009, 10:32 PM
Puffin617 Puffin617 is offline Changing all different font sizes by a value Windows XP Changing all different font sizes by a value Office 2003
Novice
Changing all different font sizes by a value
 
Join Date: May 2009
Posts: 5
Puffin617 is on a distinguished road
Default Changing all different font sizes by a value

Hi,



Say for instance I have a document with different font sizes. Is it possible to increase all different sizes by 3 point for example... i.e, all 10 pt becomes 13pt and all 26pt becomes 29pt?

Regards,
Barend
Reply With Quote
  #2  
Old 05-20-2009, 11:45 PM
Bird_FAT's Avatar
Bird_FAT Bird_FAT is offline Changing all different font sizes by a value Changing all different font sizes by a value Office 2007
Expert
 
Join Date: Apr 2009
Location: South East
Posts: 271
Bird_FAT is on a distinguished road
Default

Copy the following VBA code and change the values needed - if you are doing multiple replaces in one go, then copy the code 'from' and 'to' points and paste after the 'to' point and change again. You can repeat the code as many times as needed in one piece of code. (see green notations in the CODE)

Code:
Sub Alter_Text_Size()
'
' Created by Bird_FAT 21/05/2009
'
    Selection.Find.ClearFormatting    '<------Repeat from here
        
    With Selection.Find
        .Text = "*"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .Font.Size = 11                    '<------ Change the Font size
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .MatchWildcards = True
    End With
    While Selection.Find.Execute
    Selection.Font.Size = 14            '<------ Change the Font size
    Wend                                     '<------Repeat to here
                                           '<------Paste copied section here
End Sub
Reply With Quote
  #3  
Old 05-21-2009, 01:24 AM
Puffin617 Puffin617 is offline Changing all different font sizes by a value Windows XP Changing all different font sizes by a value Office 2003
Novice
Changing all different font sizes by a value
 
Join Date: May 2009
Posts: 5
Puffin617 is on a distinguished road
Default

Hey,

Thanx for the help but my problem is still not solved...

I'm not "looking" for specific font sizes in my document but want to change ALL font sizes up by a specific amount...

I've written a form to ask the user for the size increase but how do I apply this to all font sizes?

Is there a way to move through the document and save the fontsize AT THE CURSOR to a variable?

I'm well clued up with Excel VBA but not Word...

Thanx
Reply With Quote
  #4  
Old 05-21-2009, 01:31 AM
Puffin617 Puffin617 is offline Changing all different font sizes by a value Windows XP Changing all different font sizes by a value Office 2003
Novice
Changing all different font sizes by a value
 
Join Date: May 2009
Posts: 5
Puffin617 is on a distinguished road
Default

Hey,

Figured it out :

I removed the .Font.Size = 12 from the "find" command and replaced

Selection.Font.Size = 14
with
Selection.Font.Size = Selection.Font.Size + 14

where 14 is my value i get from my User form

Thanx
Reply With Quote
  #5  
Old 05-21-2009, 02:05 AM
Puffin617 Puffin617 is offline Changing all different font sizes by a value Windows XP Changing all different font sizes by a value Office 2003
Novice
Changing all different font sizes by a value
 
Join Date: May 2009
Posts: 5
Puffin617 is on a distinguished road
Default

NEW PROBLEM :

The font replacement does not stay within my selected text. It runs past to the end of the document then starts again at the beginning and keeps on in an infinite loop...

Here is my Code so far :

Code:
Private Sub CommandButton1_Click()

        'Application.ScreenUpdating = False
        
        SizeIncrease = TextBox1.Value
        
        If SizeIncrease = "" Then
                End
        End If
        
        Selection.Find.ClearFormatting                  '<------Repeat from here

        With Selection.Find
                .Text = "*"
                .Replacement.Text = ""
                .Forward = True
                .Wrap = wdFindContinue
                .Format = True
                '.Font.Size = 12                                           '<------ Finding a font with size "12"
                .MatchCase = False
                .MatchWholeWord = False
                .MatchWildcards = False
                .MatchSoundsLike = False
                .MatchAllWordForms = False
                .MatchWildcards = True
        End With
    
        While Selection.Find.Execute
                If OptionButton1 = True Then
                        Selection.Font.Size = Selection.Font.Size + SizeIncrease            '<------ Change the Font size
                Else
                        If Selection.Font.Size - SizeIncrease >= 1 Then
                                Selection.Font.Size = Selection.Font.Size - SizeIncrease            '<------ Change the Font size
                        Else
                                Selection.Font.Size = 1            '<------ Change the Font size
                        End If
                End If
        Wend
        
        'Application.ScreenUpdating = False
        
        frmChangeFontSize.Hide
        
End Sub
Attached is the VBA form that I use...

Your help would be appreciated...
Attached Files
File Type: zip frmChangeFontSize.zip (1.5 KB, 5 views)
Reply With Quote
  #6  
Old 05-21-2009, 06:46 AM
Bird_FAT's Avatar
Bird_FAT Bird_FAT is offline Changing all different font sizes by a value Changing all different font sizes by a value Office 2007
Expert
 
Join Date: Apr 2009
Location: South East
Posts: 271
Bird_FAT is on a distinguished road
Default

Try putting the While - Wend statement inside the If statement rather than around it
Code:
    If OptionButton1 = True Then
        While Selection.Find.Execute
                Selection.Font.Size = Selection.Font.Size + SizeIncrease
        Wend
    Else
        >ETC,ETC,ETC<
Does that fix the issue?
Reply With Quote
  #7  
Old 05-21-2009, 08:23 AM
Puffin617 Puffin617 is offline Changing all different font sizes by a value Windows XP Changing all different font sizes by a value Office 2003
Novice
Changing all different font sizes by a value
 
Join Date: May 2009
Posts: 5
Puffin617 is on a distinguished road
Default

Hey,

NO-GO... Here is my code so far...

Code:
Private Sub CommandButton1_Click()

    'Application.ScreenUpdating = False
    
    SizeIncrease = TextBox1.Value
    
    If SizeIncrease = "" Then
        End
    End If
    
    Selection.Find.ClearFormatting        '<------Repeat from here

    With Selection.Find
        .Text = "*"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .MatchWildcards = True
    End With

    If OptionButton1 = True Then
        While Selection.Find.Execute
            Selection.Font.Size = Selection.Font.Size + SizeIncrease
        Wend
    Else
        While Selection.Find.Execute
            Selection.Font.Size = Selection.Font.Size - SizeIncrease
        Wend
    End If

    'Application.ScreenUpdating = False
    
    frmChangeFontSize.Hide
        
End Sub
It just continues right past the end of the selection...

A thought : What does the ".wrap" in the find do?
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing all different font sizes by a value Type spacing and point sizes in Word funky Word 3 01-14-2009 09:18 PM
Changing all different font sizes by a value Font colors JerryB Excel 1 11-30-2008 10:23 AM
need help with font color samsongee Word 0 09-07-2006 10:18 PM
IRR with Changing Signs aml480 Excel 0 03-16-2006 11:27 PM
Changing all different font sizes by a value Font Problem with Richtextbox in MS Access Report surendrababu Office 2 11-29-2005 02:11 AM


All times are GMT -7. The time now is 08:34 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2020 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft