![]() |
|
#4
|
||||
|
||||
|
Another way:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim Rng As Range
Application.CheckLanguage = True
With Selection
Set Rng = .Range
.LanguageID = wdFrenchCanadian
.NoProofing = False
With .Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "<[JFMASOND][abceglnoprtuvy]{2} [0-9]{1;2}, [0-9]{2}>"
.Replacement.Text = ""
.MatchWildcards = True
.Wrap = wdFindStop
.Forward = True
.Format = False
End With
Do While .Find.Execute
If .InRange(Rng) Then
Select Case Split(.Text, " ")(0)
Case "Jan": .Text = Split(Split(.Text, " ")(1), ",")(0) & " janv. 20" & Split(.Text, " ")(2)
Case "Feb": .Text = Split(Split(.Text, " ")(1), ",")(0) & " févr. 20" & Split(.Text, " ")(2)
Case "Mar": .Text = Split(Split(.Text, " ")(1), ",")(0) & " mars 20" & Split(.Text, " ")(2)
Case "Apr": .Text = Split(Split(.Text, " ")(1), ",")(0) & " avr. 20" & Split(.Text, " ")(2)
Case "May": .Text = Split(Split(.Text, " ")(1), ",")(0) & " mai 20" & Split(.Text, " ")(2)
Case "Jun": .Text = Split(Split(.Text, " ")(1), ",")(0) & " juin 20" & Split(.Text, " ")(2)
Case "Jul": .Text = Split(Split(.Text, " ")(1), ",")(0) & " juill. 20" & Split(.Text, " ")(2)
Case "Aug": .Text = Split(Split(.Text, " ")(1), ",")(0) & " août 20" & Split(.Text, " ")(2)
Case "Sep": .Text = Split(Split(.Text, " ")(1), ",")(0) & " sept. 20" & Split(.Text, " ")(2)
Case "Oct": .Text = Split(Split(.Text, " ")(1), ",")(0) & " oct. 20" & Split(.Text, " ")(2)
Case "Nov": .Text = Split(Split(.Text, " ")(1), ",")(0) & " nov. 20" & Split(.Text, " ")(2)
Case "Dec": .Text = Split(Split(.Text, " ")(1), ",")(0) & " déc. 20" & Split(.Text, " ")(2)
End Select
.Font.Color = 16711937 'Blue HTML 1/1/255
Else
Exit Do
End If
.Collapse wdCollapseEnd
Loop
End With
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
| Tags |
| help me, range, selection |
|
|
Similar Threads
|
||||
| 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 |