1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
Sub SwapXY()
'
'
'
Selection.Find.ClearFormatting
With Selection.Find
.Text = "L Y"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
While Selection.Find.Execute
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
chaine = Selection.Text
posY = InStr(1, Selection.Text, "Y")
posX = InStr(1, Selection.Text, "X")
posR = InStr(1, Selection.Text, "R")
chaine = Left(Selection.Text, posY - 1) + Mid(Selection.Text, posX, posR - posX) + Mid(Selection.Text, posY, posX - posY) + Mid(Selection.Text, posR, Len(Selection.Text) - posR + 1)
Selection.Text = chaine
Wend
End Sub |
Partager