Bonjour,
Je voudrais faire des macros dans Word, pour faire des suppressions automatiques ou des déplacements automatiques de paragraphes standardisés.
J'ai créé une macro via le machin Word qui enregistre les actions faites au clavier (moi-même je sais pas écrire de code Visual Basic, je n'y connais rien du tout), le problème, c'est que je sais pas comment faire une boucle pour que les actions se fassent sur chaque nouveau paragraphe et ce jusqu'à la fin du document Word: ça s'arrête à la fin du premier paragraphe.
Je suis débutant et je comprends pas encore bien le Visual Basic, alors je crois qu'il y a un truc avec "Loop" mais je sais pas comment faire concrètement et je comprends pas ce que je peux voir sur internet à ce sujet...
Est-ce que qn peut m'aider? Merci d'avance.
Je vous poste le code obtenu jusqu'à présent:
Sub XmlToLpEffacerChampsInutiles()
'
' XmlToLpEffacerChampsInutiles Macro
' Macro enregistrée le 09/11/2013 par JeanClaude
'
Selection.Find.ClearFormatting
With Selection.Find
.Text = "<identifiant>"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveDown Unit:=wdParagraph, Count:=1,
Extend:=wdExtend
Selection.TypeBackspace
Selection.Find.ClearFormatting
With Selection.Find
.Text = "<image>"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveDown Unit:=wdParagraph, Count:=3,
Extend:=wdExtend
Selection.TypeBackspace
Selection.Find.ClearFormatting
With Selection.Find
.Text = "<enqueteur>"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveDown Unit:=wdParagraph, Count:=11,
Extend:=wdExtend
Selection.TypeBackspace
Selection.Find.ClearFormatting
With Selection.Find
.Text = "<DonneesMorpho>"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveDown Unit:=wdParagraph, Count:=2,
Extend:=wdExtend
Selection.TypeBackspace
Selection.Find.ClearFormatting
With Selection.Find
.Text = "<type>"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveDown Unit:=wdParagraph, Count:=9,
Extend:=wdExtend
Selection.TypeBackspace
End Sub