Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Pour MiMa - Procédure sur la gestion des sauts de page

1 réponse
Avatar
michdenis
3 tentatives effectuées pour diriger cet envoi directement
à la suite du fil sans succès !


| Mais il me laisse sur mes interrogations sur la
| façon de gérer les sauts.

Tu retrouves le code publié dans ce message à
cette adresse sous la plume de Helmut Weber.

http://www.officekb.com/Uwe/Forum.aspx/word-vba/8919/Determining-which-type-of-breaks-are-present-on-a-page

Tu copies ce qui suit dans un module standard.
'---------------------------------------------
Sub test012()
Dim rDcm As Range ' the documents range
Set rDcm = ActiveDocument.Range
Selection.StartOf Unit:=wdStory, Extend:=wdMove
With Selection.Find
.Text = Chr(12)
While .Execute
MsgBox KindofBreak12(Selection.Range)
Wend
End With
'wdSectionContinuous ' 0
'wdSectionNewColumn ' 1
'wdSectionNewPage ' 2
'wdSectionEvenPage ' 3
'wdSectionOddPage '4

End Sub
'---------------------------------------------
Public Function KindofBreak12(ByVal rTmp As Range) As String
Dim lSct1 As Long ' counter for sections
Dim lSct2 As Long ' counter for sections
Dim lKoSc As Long ' kind of section.pagesetup.sectionstart
rTmp.Start = ActiveDocument.Range.Start
lSct1 = rTmp.Sections.Count ' count sections
rTmp.End = rTmp.End + 1 ' extend range
lSct2 = rTmp.Sections.Count ' count sections again
If lSct1 = lSct2 Then ' next caracter is in the same section
KindofBreak12 = "ordinary page break"
Exit Function
End If
' next character is in the next section
lKoSc = ActiveDocument.Sections(lSct2).PageSetup.SectionStart
Select Case lKoSc
Case 0: KindofBreak12 = "wdSectionContinuous"
Case 2: KindofBreak12 = "wdSectionNewPage"
Case 3: KindofBreak12 = "wdSectionEvenPage"
Case 4: KindofBreak12 = "wdSectionOddPage"
End Select

End Function
'---------------------------------------------

1 réponse

Avatar
MiMa
Bonjour michdenis
Ton message s'est bien inscrit dans le fil de la discution.
Je te remercie pour ces renseignements qui répondent à mes intérrogations.
Même si je ne les utilise pas immédiatement, je n'aime pas rester sur une
situation en supend.
Grace à ton intervention précédente et aux suggestion de Geo, je suis arrivé
à bout de mon projet.
Merci encore
a+
MiMa


"michdenis" a écrit dans le message de news:

3 tentatives effectuées pour diriger cet envoi directement
à la suite du fil sans succès !


| Mais il me laisse sur mes interrogations sur la
| façon de gérer les sauts.

Tu retrouves le code publié dans ce message à
cette adresse sous la plume de Helmut Weber.

http://www.officekb.com/Uwe/Forum.aspx/word-vba/8919/Determining-which-type-of-breaks-are-present-on-a-page

Tu copies ce qui suit dans un module standard.
'---------------------------------------------
Sub test012()
Dim rDcm As Range ' the documents range
Set rDcm = ActiveDocument.Range
Selection.StartOf Unit:=wdStory, Extend:=wdMove
With Selection.Find
.Text = Chr(12)
While .Execute
MsgBox KindofBreak12(Selection.Range)
Wend
End With
'wdSectionContinuous ' 0
'wdSectionNewColumn ' 1
'wdSectionNewPage ' 2
'wdSectionEvenPage ' 3
'wdSectionOddPage '4

End Sub
'---------------------------------------------
Public Function KindofBreak12(ByVal rTmp As Range) As String
Dim lSct1 As Long ' counter for sections
Dim lSct2 As Long ' counter for sections
Dim lKoSc As Long ' kind of section.pagesetup.sectionstart
rTmp.Start = ActiveDocument.Range.Start
lSct1 = rTmp.Sections.Count ' count sections
rTmp.End = rTmp.End + 1 ' extend range
lSct2 = rTmp.Sections.Count ' count sections again
If lSct1 = lSct2 Then ' next caracter is in the same section
KindofBreak12 = "ordinary page break"
Exit Function
End If
' next character is in the next section
lKoSc = ActiveDocument.Sections(lSct2).PageSetup.SectionStart
Select Case lKoSc
Case 0: KindofBreak12 = "wdSectionContinuous"
Case 2: KindofBreak12 = "wdSectionNewPage"
Case 3: KindofBreak12 = "wdSectionEvenPage"
Case 4: KindofBreak12 = "wdSectionOddPage"
End Select

End Function
'---------------------------------------------