OVH Cloud OVH Cloud

suite...

1 réponse
Avatar
Serge Hipontoise
Sub InsertionEntreParentheses()
Selection.Paragraphs.First.Range.InsertBefore "("
Selection.Paragraphs.First.Range.Characters.Last.InsertBefore ")"
Selection.MoveRight Unit:=wdCharacter, Count:=2
End Sub

qui le fait très bien

Mais comment pourrais-je faire pour déterminer si ce paragraphe en question
n'est pas déjà entouré de parenthèses, afin d'éviter les répétitions
possibles : ((Mon paragraphe)) ?

Merci

Serge

1 réponse

Avatar
Rémi
Bonjour

Essaies le code suivant

Sub InsertionEntreParentheses(
Selection.HomeKey Unit:=wdLin
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExten
If Selection.Text <> "(" The
Selection.Paragraphs.First.Range.InsertBefore "(
Selection.Paragraphs.First.Range.Characters.Last.InsertBefore ")
Selection.MoveRight Unit:=wdCharacter, Count: End I
End Su

Cordialement

Rémi

----- Serge Hipontoise wrote: ----

Sub InsertionEntreParentheses(
Selection.Paragraphs.First.Range.InsertBefore "(
Selection.Paragraphs.First.Range.Characters.Last.InsertBefore ")
Selection.MoveRight Unit:=wdCharacter, Count: End Su

qui le fait très bie

Mais comment pourrais-je faire pour déterminer si ce paragraphe en questio
n'est pas déjà entouré de parenthèses, afin d'éviter les répétition
possibles : ((Mon paragraphe))

Merc

Serg