Saut de Page en VBA word 2000 !!!
Résolu
glaine
Messages postés
29
Date d'inscription
Statut
Membre
Dernière intervention
-
glaine Messages postés 29 Date d'inscription Statut Membre Dernière intervention -
glaine Messages postés 29 Date d'inscription Statut Membre Dernière intervention -
A voir également:
- Saut de Page en VBA word 2000 !!!
- Supprimer une page word - Guide
- Word 2013 - Télécharger - Traitement de texte
- Tableau word - Guide
- Numéro de page word - Guide
- Espace insécable word - Guide
2 réponses
La solution, pour ceux que cela intéresse:
Sub rechercherRemplacer()
Dim booTrouve As Boolean
Dim inti As Integer
Dim T As Variant
Selection.HomeKey unit:=wdStory
Do
With Selection.Find 'Recherche
.Text = "03/11/2009" 'Mot recherché
.Forward = True
.Wrap = wdFindStop
End With
booTrouve = Selection.Find.Execute 'Exécution de la recherche
If booTrouve Then
Selection.Collapse Direction:=wdCollapseEnd 'suppression de la sélection vers la fin du mot
Selection.InsertBreak Type:=wdPageBreak ' Insertion du saut de page
inti = inti + 1 'contrôle du nombre d'occurences
End If
Debug.Print inti 'Affichage de l'occurence
Loop While booTrouve
T = ActiveDocument.Content.ComputeStatistics(wdStatisticPages)
Selection.GoTo What:=wdGoToPage, Which:=GoToAbsolute, Count:=T
Selection.Delete
With ActiveDocument.Paragraphs
If Left(.Item(.Count).Range, 1) = Chr$(12) Then
.Item(.Count).Range.Delete
End If
End With
Selection.HomeKey unit:=wdStory
End Sub
Sub rechercherRemplacer()
Dim booTrouve As Boolean
Dim inti As Integer
Dim T As Variant
Selection.HomeKey unit:=wdStory
Do
With Selection.Find 'Recherche
.Text = "03/11/2009" 'Mot recherché
.Forward = True
.Wrap = wdFindStop
End With
booTrouve = Selection.Find.Execute 'Exécution de la recherche
If booTrouve Then
Selection.Collapse Direction:=wdCollapseEnd 'suppression de la sélection vers la fin du mot
Selection.InsertBreak Type:=wdPageBreak ' Insertion du saut de page
inti = inti + 1 'contrôle du nombre d'occurences
End If
Debug.Print inti 'Affichage de l'occurence
Loop While booTrouve
T = ActiveDocument.Content.ComputeStatistics(wdStatisticPages)
Selection.GoTo What:=wdGoToPage, Which:=GoToAbsolute, Count:=T
Selection.Delete
With ActiveDocument.Paragraphs
If Left(.Item(.Count).Range, 1) = Chr$(12) Then
.Item(.Count).Range.Delete
End If
End With
Selection.HomeKey unit:=wdStory
End Sub
Bonjour à tous,
Suite à certaines suggestions, j'ai changé un peu mon code, mais il me reste un petit soucis : comment supprimer le dernier saut de page correspondant à la dernière occurence trouvée, afin d'éviter une page vierge et inutile en fin de document ??? (DeleteBreak n'existant pas) Merci encore pour toutes les aides apportées.
Sub rechercherRemplacer()
Dim booTrouve As Boolean
Dim inti As Integer
Dim T As Variant
Selection.Start = ActiveDocument.Content.Start
Selection.End = ActiveDocument.Content.Start
Do
With Selection.Find 'Recherche
.Text = "03/11/2009" 'Mot recherché
.Forward = True
.Wrap = wdFindStop
End With
booTrouve = Selection.Find.Execute 'Exécution de la recherche
If booTrouve Then
Selection.Collapse Direction:=wdCollapseEnd 'suppression de la sélection vers la fin du mot
Selection.InsertBreak Type:=wdPageBreak ' Insertion du saut de page
inti = inti + 1 'contrôle du nombre d'occurences
End If
Debug.Print inti 'Affichage de l'occurence
Loop While booTrouve
T = ActiveDocument.Content.ComputeStatistics(wdStatisticPages)
Selection.GoTo What:=wdGoToPage, Which:=GoToAbsolute, Count:=T
Selection.Delete
If inti = T Then
Selection.Start = ActiveDocument.Content.Start
Selection.End = ActiveDocument.Content.Start
End Sub
Suite à certaines suggestions, j'ai changé un peu mon code, mais il me reste un petit soucis : comment supprimer le dernier saut de page correspondant à la dernière occurence trouvée, afin d'éviter une page vierge et inutile en fin de document ??? (DeleteBreak n'existant pas) Merci encore pour toutes les aides apportées.
Sub rechercherRemplacer()
Dim booTrouve As Boolean
Dim inti As Integer
Dim T As Variant
Selection.Start = ActiveDocument.Content.Start
Selection.End = ActiveDocument.Content.Start
Do
With Selection.Find 'Recherche
.Text = "03/11/2009" 'Mot recherché
.Forward = True
.Wrap = wdFindStop
End With
booTrouve = Selection.Find.Execute 'Exécution de la recherche
If booTrouve Then
Selection.Collapse Direction:=wdCollapseEnd 'suppression de la sélection vers la fin du mot
Selection.InsertBreak Type:=wdPageBreak ' Insertion du saut de page
inti = inti + 1 'contrôle du nombre d'occurences
End If
Debug.Print inti 'Affichage de l'occurence
Loop While booTrouve
T = ActiveDocument.Content.ComputeStatistics(wdStatisticPages)
Selection.GoTo What:=wdGoToPage, Which:=GoToAbsolute, Count:=T
Selection.Delete
If inti = T Then
Selection.Start = ActiveDocument.Content.Start
Selection.End = ActiveDocument.Content.Start
End Sub