| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 
 | Public NomFeuille
Sub Protéger()
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="HDR"
    ActiveWorkbook.Protect Structure:=True, Windows:=False, Password:="HDR"
End Sub
---------------
Sub Deprotéger()
    'ActiveSheet.Unprotect
    ActiveSheet.Unprotect Password:="HDR"
    ActiveWorkbook.Unprotect Password:="HDR" 'Structure:=false, Windows:=False
 
End Sub
--------------
Sub Nouvelle_facture()
'Modifié le 02/05/2012 par PGI
Application.ScreenUpdating = False
        Réponse = MsgBox("Confirmez vous la création ?", vbOKCancel)
        If Réponse = vbOK Then
            Sheets("Accueil").Select
            NomFeuille = Worksheets("Accueil").Range("Compteur_Fact")
             Sheets("Accueil").Select
            Deprotéger
            Range("Compteur_Fact") = NomFeuille + 1
            Sheets("Accueil").Select
            ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="HDR"
 
            On Error Resume Next
            If NomFeuille = "" Then Exit Sub
'Modifié le 02/05/2012 par PGI
'Application.ScreenUpdating = False
 
            Sheets("Modèle").Visible = True
            Deprotéger
            Sheets("Modèle").Copy after:=Sheets(3)
            Deprotéger
            ActiveSheet.Name = NomFeuille
            Range("Num_Fact") = NomFeuille
            'Protéger
            'Range("Num_Fact") = NomFeuille
            If Err <> 0 Then
                Err.Clear
                Application.DisplayAlerts = False
                Sheets(4).Delete
                msg = "Le nom de feuille que vous avez tapé n'est pas valide !" _
                & Chr(13) + Chr(10)
                'Modifié le 02/05/2012 par PGI
                '& vbCrLf
                msg = msg & Chr(13) + Chr(10)
                'Modifié le 02/05/2012 par PGI
                ' & vbCrLf
                msg = msg & "- Vérifiez que le nom de la feuille ne dépasse " _
                & "pas 31 caractères" & Chr(13) + Chr(10)
                'Modifié le 02/05/2012 par PGI
                '& vbCrLf
                msg = msg & "- Vérifiez que le nom de la feuille ne contient " _
                & "aucun des caractères suivants :" & Chr(13) + Chr(10)
                'Modifié le 02/05/2012 par PGI
                '& vbCrLf
                msg = msg & " \ / : ? * [ ou ]" & Chr(13) + Chr(10)
                'Modifié le 02/05/2012 par PGI
                ' & vbCrLf
                msg = msg & "- Vérifiez qu'une feuille du classeur ne possède " _
                & "pas déjà un nom identique" & Chr(13) + Chr(10)
                'Modifié le 02/05/2012 par PGI
                ' & vbCrLf
                Reponse = MsgBox(msg, , "Saisie invalide")
                'Nouvelle_facture
            End If
                Sheets(4).Select
 
            Else
        End If
 
                  Sheets("Accueil").Select
            ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="HDR"
        Sheets("Modèle").Select
        ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="HDR"
      Sheets("Modèle").Visible = False
'Modifié le 02/05/2012 par PGI
'        Application.ScreenUpdating = True
      Sheets(4).Select
      Protéger
'        Sheets(NomFeuille).Select
'Modifié le 02/05/2012 par PGI
       Application.ScreenUpdating = True
End Sub | 
Partager