Marine_blatz
XLDnaute Nouveau
Bonjour à tous j'ai une erreur lors de l'exécution de ce code quelqu'un sais til pourquoi ?
Voir code et capture ci contre
	
	
	
	
	
		
	
		
			
		
		
	
				
			Voir code et capture ci contre
		VB:
	
	
	Sub rapport_provisoire_entete()
Dim Prgrf As Paragraph
Dim reg As New VBScript_RegExp_55.RegExp, Match As VBScript_RegExp_55.Match
Dim Matches As VBScript_RegExp_55.MatchCollection
    Set reg = New VBScript_RegExp_55.RegExp
    reg.Pattern = "(rapport)( )(\d{2})"
    reg.Global = True
    For Each Prgrf In ThisDocument.Sections(1).Headers(1).Range.Paragraphs
        If InStr(Prgrf.Range.Text, "rapport") Then
            Set Matches = reg.Execute(Prgrf.Range.Text)
            For Each Match In Matches
                Remplace_dans_Header 1, 1, Match.Value, "rapport provisoire"
            Next Match
        End If
    Next Prgrf
End Sub
Sub Remplace_dans_Header(Sct As Byte, Hdr As Byte, S1 As String, S2 As String)
    With ThisDocument.Sections(Sct).Headers(Hdr).Range.Find
        .Text = S1
        .Forward = False
        .Execute
        If .Found Then .Parent.Text = S2
    End With
End Sub