![]() |
#1
|
||||
|
||||
![]()
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 Last edited by Cendrinne; 01-26-2025 at 09:31 PM. |
Tags |
help me, range, selection |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Count lines within selected text range | eduzs | Word VBA | 4 | 09-17-2023 05:22 PM |
Change background of selected text | ultrarunner2020 | Word | 5 | 03-10-2023 02:59 PM |
Applying a VBA code only on a selected text or range | RobertDany | Word VBA | 2 | 10-09-2021 08:31 AM |
How to change color indicating selected text | daylee | Word | 1 | 03-27-2019 01:31 PM |
Please help. I want to change the text of a cell when another is selected | frankzelnik | Excel | 5 | 06-19-2018 01:34 PM |