Dim Debut As Long, Fin As Long, Ligne As Long, Texte As String
Dim NomModule As String
With ThisWorkbook
With .VBProject.VBComponents("Module1").CodeModule 'Module 1
Debut = .ProcStartLine(NomMacro, vbext_pk_Proc)
Fin = .ProcCountLines(NomMacro, 0) + Debut - 1
If Left(.Lines(Debut + 1, 1), 4) = "'Ina" Then
MsgBox ("déjà inactive")
Else
.ReplaceLine Debut + 1, "'Inactive"
For Ligne = Debut + 2 To Fin - 1
If .Lines(Ligne, 1) <> "" And Left(.Lines(Ligne, 1), 3) <> "Sub" Then
Texte = "'" & .Lines(Ligne, 1)
.ReplaceLine (Ligne), Texte
End If
Next
End If
End With
End With
End Sub
Sub DéCommenter(NomMacro As String)
Dim Debut As Long, Fin As Long, Ligne As Long, Texte As String
Dim NomModule As String
With ThisWorkbook
With .VBProject.VBComponents("Module1").CodeModule 'Module 1
Debut = .ProcStartLine(NomMacro, vbext_pk_Proc)
Fin = .ProcCountLines(NomMacro, 0) + Debut - 1
If Left(.Lines(Debut + 1, 1), 4) = "'Act" Then
MsgBox ("déjà active")
Else
.ReplaceLine Debut + 1, "'Active"
For Ligne = Debut + 2 To Fin - 1
If .Lines(Ligne, 1) <> "" Then
Texte = .Lines(Ligne, 1)
Texte = Right(Texte, Len(Texte) - 1)
.ReplaceLine (Ligne), Texte
End If
Next
End If
End With
End With
End Sub