View Single Post
 
Old 01-26-2025, 02:39 PM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Windows 10 Office 2019
Competent Performer
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 200
Cendrinne is on a distinguished road
Question Help, How to have only a selected text to change = Range

Hi Pros,
I've had notes to select text to Find and Replace only what I've selected, but both Notes I had, doesn't work. So I'm not certain what I'm doing wrong.

So I have text prior, that didn't get touch, it's going forward.

For example, Dates, I wish to modify from a format to another format + Language.

Is there a way to select a Specific Range to modify? Nothing before and nothing afterwards?

If so, please guide me, cause all my text is being changed.

Code:
Dim oRng As Range
   Application.ScreenUpdating = False
   
    Set oRng = ActiveDocument.Range(Start:=Selection.Range.Start, End:=Selection.Range.End)
    
    Selection.Select
    Selection.languageID = wdFrenchCanadian
    Selection.NoProofing = False
    Application.CheckLanguage = True
    
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Color = 16711937                             'Blue HTML 1/1/255

    With Selection.Find
        .Forward = True
        .Wrap = wdFindStop
        .Format = True
        .MatchCase = True
        .MatchWildcards = True
        
        .text = "([A-Z][a-z]{2})( {1})([0-9]{1;2})(,)( )([0-9]{2})"
        .Replacement.text = "\3 \1\2 20\6"
    Selection.Find.Execute Replace:=wdReplaceAll
    End With
    
   
' Ajt_Select_Col_Mod_Langue_a_Fr Macro
'
    Set oRng = ActiveDocument.Range(Selection.Range.Start, Selection.Range.End)

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Color = 16711937                                   'Blue HTML 1/1/255
    With Selection.Find
        .Forward = True
        .Wrap = wdFindStop
        .Format = True
        .MatchCase = True
        .MatchWildcards = False
        
        .text = "Jan"
        .Replacement.text = "janv."
    Selection.Find.Execute Replace:=wdReplaceAll
    
        .text = "Feb"
        .Replacement.text = "févr."
    Selection.Find.Execute Replace:=wdReplaceAll
    
        .text = "Mar"
        .Replacement.text = "mars"
    Selection.Find.Execute Replace:=wdReplaceAll
        
        .text = "Apr"
        .Replacement.text = "avr."
    Selection.Find.Execute Replace:=wdReplaceAll
        
        .text = "May"
        .Replacement.text = "mai"
    Selection.Find.Execute Replace:=wdReplaceAll
    
        .text = "Jun"
        .Replacement.text = "juin"
    Selection.Find.Execute Replace:=wdReplaceAll
    
        .text = "Jul"
        .Replacement.text = "juill."
    Selection.Find.Execute Replace:=wdReplaceAll
    
        .text = "Aug"
        .Replacement.text = "août"
    Selection.Find.Execute Replace:=wdReplaceAll
    
        .text = "Sep"
        .Replacement.text = "sept."
    Selection.Find.Execute Replace:=wdReplaceAll
    
        .text = "Oct"
        .Replacement.text = "oct."
    Selection.Find.Execute Replace:=wdReplaceAll
    
        .text = "Nov"
        .Replacement.text = "nov."
    Selection.Find.Execute Replace:=wdReplaceAll
    
        .text = "Dec"
        .Replacement.text = "déc."
    Selection.Find.Execute Replace:=wdReplaceAll
    End With
Any insights would be very appreciated.

Last edited by Cendrinne; 01-26-2025 at 09:31 PM.
Reply With Quote