View Single Post
 
Old 08-04-2023, 10:19 AM
MLe MLe is offline Windows 11 Office 2021
Novice
 
Join Date: Aug 2023
Posts: 1
MLe is on a distinguished road
Default Find out how to change all letter of first word using VBA ?

Hi,
Sorry Sorry sorry for my english

For my dissertation today at more than 400 pages, I would like to change the style and box of certain words. I found my happiness ... well almost.
In the example below, I need to modify "DESCRIPTION" in one style and "-- remplissage" in another style
This is my macro :

Code:
Sub change ()
Application.ScreenUpdating = False
Selection.HomeKey Unit:=wdStory
    Do
        With Selection.Find
            .ClearFormatting
            .Text = "COORDINATION"
            .MatchWholeWord = True 
            .Font.Bold = False
            .Font.Underline = True 
            .Style = "Souligné"
            .MatchCase = True
            .Wrap = wdFindStop
            .Execute
        End With
    If Selection.Find.Found Then
    Selection.Style = ActiveDocument.Styles("NORMAL_01")
               Selection.Range.Case = wdUpperCase
                 End If
     Loop Until Not Selection.Find.Found
End Sub
It's good except that it changes ALL the words "description" and I only want if this one is in capitals or if this one is at the beginning of a sentence

EX :
DESCRIPTION (yes)
This is a description (NO) de my car ...

Thanks in advance and sorry for my english
Reply With Quote