IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Macros et VBA Excel Discussion :

Excel se ferme lors de l'exécution de macro [XL-2013]


Sujet :

Macros et VBA Excel

  1. #1
    Membre régulier
    Homme Profil pro
    Chargé d'affaire
    Inscrit en
    Février 2008
    Messages
    143
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Pyrénées Orientales (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Chargé d'affaire
    Secteur : Service public

    Informations forums :
    Inscription : Février 2008
    Messages : 143
    Points : 106
    Points
    106
    Par défaut Excel se ferme lors de l'exécution de macro
    Bonjour le forum,

    Je reviens vers vous car là je cale.

    J'ai créer une application sur excel utilisant que des forms, l'utilisateur n'a jamais accès aux feuilles.
    Cette application fonctionne très bien sans protection du code VBA.

    Dès que je protège le fichier EXCEL se ferme à l'éxécution d'une SUB.
    J'ai déjà traité un premier problème en recréant entièrement le form et le problème s'est réglé.
    J'ai consulté sur internet les causes et j'ai repris mon programme en modifiant mes erreurs : plus de goto hormis gestion d'erreur et bien refermer les variables objet.

    Le programme a refonctionné correctement, mais l'erreur revient sur un autre form ???
    Refaire le form règle le problème mais d'où peut venir ce problème ?

    Merci pour vos conseils avisés

  2. #2
    Expert éminent sénior Avatar de Menhir
    Homme Profil pro
    Ingénieur
    Inscrit en
    Juin 2007
    Messages
    16 037
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : Ingénieur
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2007
    Messages : 16 037
    Points : 32 866
    Points
    32 866
    Par défaut
    Sans connaitre ni le code, ni le message d'erreur, ni la ligne de code qui renvoi l'erreur, ni la nature de la form, comment penses-tu qu'il soit possible de faire une réponse constructive ?

    La seule chose que je vois à te conseiller, c'est de désactiver la gestion d'erreur pour que l'exécution puisse te fournir le maximum d'informations sur le problème.
    Merci de cliquer sur pour chaque message ayant aidé puis sur pour clore cette discussion.

  3. #3
    Membre régulier
    Homme Profil pro
    Chargé d'affaire
    Inscrit en
    Février 2008
    Messages
    143
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Pyrénées Orientales (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Chargé d'affaire
    Secteur : Service public

    Informations forums :
    Inscription : Février 2008
    Messages : 143
    Points : 106
    Points
    106
    Par défaut
    Bonjour,


    Merci Menhir pour ta réponse, mais il me semble que le problème ne vienne pas de la sub.

    J'ai avancé depuis sur le problème.

    vous trouverez ci dessous la sub en question :
    elle est situé dans le form qui l'appelle :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    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
     
    Option Explicit
     
    Dim valeur As Variant
    Dim a As Single
    Dim nume As String
    Dim nume1 As String
    Dim nume2 As String
    Dim num1 As Integer
    Dim num2 As Integer
    Dim num3 As Integer
    Dim num4 As Integer
    Dim cont As String
    Dim lig As Integer
    Dim ok As Boolean
    Dim retform As Boolean
    Private Sub CommandButton11_Click()
     
    valeur = cherchcommune(0, True, "commune")
    nume = valeur(2)
    lig = cherchdivers(4, "commune", nume, "a", False)
    'Stop
    MsgBox "test"
    With formperm
        .saismair1.Caption = nume
        .saismair1b.Caption = nume
        .saismair2.Caption = Sheets("commune").Range("b" & lig).Value
        .saismair2b.Caption = Sheets("commune").Range("b" & lig).Value
        .saismair3.Caption = Format(Sheets("commune").Range("c" & lig).Value, "00"" ""00"" ""00"" ""00"" ""00")
        .saismair4.Caption = Sheets("commune").Range("d" & lig).Value
        .saismair5.Caption = Sheets("commune").Range("g" & lig).Value
        .saismair6.Caption = Sheets("commune").Range("h" & lig).Value
        .saismair7.Caption = Sheets("commune").Range("i" & lig).Value
        .saismair8.Caption = Sheets("commune").Range("j" & lig).Value
        .saismair9.Caption = Sheets("commune").Range("k" & lig).Value
    End With
     
    For a = 1 To 5
        formperm.Controls("saisadres" & a & "5").Value = Sheets("commune").Range("j" & lig).Value
        formperm.Controls("saisadres" & a & "6").Value = Sheets("commune").Range("b" & lig).Value
    Next a
    num1 = Sheets("commune").Range("e" & lig).Value
    num2 = Sheets("commune").Range("f" & lig).Value
     
    nume = num1
    lig = cherchdivers(4, "dde", nume, "a", False)
    With formperm
        .saisdde1.Caption = num1
        .saisdde2.Caption = Sheets("dde").Range("b" & lig).Value
        .saisdde2b.Caption = Sheets("dde").Range("b" & lig).Value
        .saisdde3.Caption = Format(Sheets("dde").Range("c" & lig).Value, "00"" ""00"" ""00"" ""00"" ""00")
        .saisdde4.Caption = Sheets("dde").Range("d" & lig).Value
        .saisdde5.Caption = Sheets("dde").Range("e" & lig).Value
        .saisdde6.Caption = Sheets("dde").Range("f" & lig).Value
        .saisdde7.Caption = Sheets("dde").Range("g" & lig).Value
        .saisdde8.Caption = Sheets("dde").Range("h" & lig).Value
        .saisdde9.Caption = Sheets("dde").Range("i" & lig).Value
    End With
     
    nume = num2
    lig = cherchdivers(4, "agglo", nume, "a", False)
    With formperm
        .saisagglo1.Caption = num2
        .saisagglo2.Caption = Sheets("agglo").Range("b" & lig).Value
        .saisagglo2b.Caption = Sheets("agglo").Range("b" & lig).Value
        .saisagglo3.Caption = Format(Sheets("agglo").Range("c" & lig).Value, "00"" ""00"" ""00"" ""00"" ""00")
        .saisagglo4.Caption = Sheets("agglo").Range("d" & lig).Value
        .saisagglo5.Caption = Sheets("agglo").Range("e" & lig).Value
        .saisagglo6.Caption = Sheets("agglo").Range("f" & lig).Value
        .saisagglo7.Caption = Sheets("agglo").Range("g" & lig).Value
        .saisagglo8.Caption = Sheets("agglo").Range("h" & lig).Value
        .saisagglo9.Caption = Sheets("agglo").Range("i" & lig).Value
    End With
    nume = Sheets("commune").Range("l" & lig).Value
    formperm.saismodelig.Caption = nume
    majformperm nume, False
    If formperm.boutenv.Caption = "ENVOYER" Then majpageperm "envoie" Else majpageperm "visu"
     
    End Sub
    Elle plante juste après le stop, mais pas à chaque fois malgré que je fasse exactement la même chose dans le programme :
    Ouvrir, exécuter l'ouverture du form et cliquez sur le bouton pour remplir une case.
    Je l'arrange, en allant sur le vba, sans changer grand chose (ajout d'une msgbox test par exemple) et puis il fonctionne parfaitement tant que je le ferme pas.
    Si je ferme le programme par le bouton quitter et que je ferme excel puis réouvre, le fichier excel se ferme mais à la seconde fois et non à la première !!!!

    L'insertion de la commande STOP ci dessus règle définitivement le problème mais je dois l'enlever pour l'utilisateur ou la simuler et relancer le programme.
    Ce n'est pas à priori un problème de variable, puisque STOP ne réinitialise pas les variables.
    J'ai fait le tour de toutes les variables objets dans le programme pour les vider après utilisation au cas où mais rien !
    Par contre si je mets une msgbox pour simuler le stop, celà plante quand même.

    ci dessous les sub dans un module qui ouvre et ferme le fichier :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    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
    Option Explicit
     
    Dim lige As Integer
    Dim lige1 As Integer
    Dim lige2 As Integer
    Dim lige3 As Integer
    Dim lige4 As Integer
    Dim nom As String
    Dim nom1 As String
    Dim nom2 As String
    Dim a As Integer
    Dim B As Integer
    Dim secu As Integer
    Dim ok As Boolean
    Dim ok1 As Boolean
    Dim result As Variant
    Dim numeret As Integer
    Dim retbox As Boolean
    Dim comptbox As Single
     
    Public thisws As Workbook
     
     
    Sub auto_open()
     
    Set thisws = Nothing
    Set thisws = Application.ActiveWorkbook
     
    Sheets("pagepres").Activate
    Application.DisplayFullScreen = True
    Load formvuegen
    chargvuegen True, False
    formvuegen.Show False
     
    End Sub
     
     
    Sub ferm()
     
    Set thisws = Nothing
    Application.DisplayFullScreen = False
    ActiveWorkbook.Save
    ActiveWorkbook.Close True
     
    End Sub
    vous avez ci dessous les sub appelé situé dans divers modules :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    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
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
     
    Option Explicit
     
    Dim chlig1 As Integer
    Dim chlig2 As Integer
    Dim chlig3 As Integer
    Dim nom1 As String
    Dim nom2 As String
    Dim nom3 As String
    Dim test1 As Boolean
    Dim test2 As Boolean
    Dim renv(3) As String
    Dim retbox As Boolean
    Dim comptbox As Single
     
    Function cherchcomm(INSEE As Integer, multi As Boolean, Optional ligdeb As Integer, Optional colcherch As String, Optional valeur As String)
     
    'pour utilisation de recherche d'une ligne : mettre multi à false et rentrer le insee
    'pour utilisation de recherche plusieurs lignes il faut utiliser en boucle cette fonction en changeant à chaque appel son numéro de ligne
    ' en mettant à true multi + en mettant une valeur quelconque dans insee + en remplissant obligatoirement les options
     
    ' renvoie une valeur de type variant : ligne, numero agglo, numero dde
     
    test1 = False
     
    If multi = False Then
        chlig1 = 4
        Do While Sheets("commune").Range("a" & chlig1).Value <> ""
            If INSEE = Sheets("commune").Range("a" & chlig1).Value Then
                renv(1) = chlig1
                renv(2) = Sheets("commune").Range("f" & chlig1).Value
                renv(3) = Sheets("commune").Range("e" & chlig1).Value
                test1 = True
                Exit Do
            End If
            chlig1 = chlig1 + 1
            If chlig1 = 10000 Then
                Load formerreur
                    formerreur.titre.Caption = "ERREUR BOUCLE"
                    formerreur.mess.Caption = "dépassement de capacite dans le programme" & vbCrLf & "CONTACTER LE CONCEPTEUR ET DONNER CE CODE ERREUR :" & vbCrLf & "sortcherchcomm1"
                formerreur.Show vbModal
                Unload formerreur
                Exit Do
            End If
        Loop
     
        If test1 = False Then
            Load formerreur
                formerreur.titre.Caption = "CODE INSEE NON TROUVE"
                formerreur.mess.Caption = "Le code insee de cette commune n est pas rentré" & vbCrLf & "veuillez rentrer la commune en utilisant les paramètres"
            formerreur.Show vbModal
            Unload formerreur
            cherchcomm = 0
        End If
    Else
        chlig1 = ligdeb
        Do While Sheets("commune").Range(colcherch & chlig1).Value <> ""
            If INSEE = Sheets("commune").Range("a" & chlig1).Value Then
                renv(1) = chlig1
                renv(2) = Sheets("commune").Range("f" & chlig1).Value
                renv(3) = Sheets("commune").Range("e" & chlig1).Value
                test1 = True
                Exit Do
            End If
            chlig1 = chlig1 + 1
            If chlig1 = 10000 Then
                Load formerreur
                    formerreur.titre.Caption = "ERREUR BOUCLE"
                    formerreur.mess.Caption = "dépassement de capacite dans le programme" & vbCrLf & "CONTACTER LE CONCEPTEUR ET DONNER CE CODE ERREUR :" & vbCrLf & "sortcherchcomm2"
                formerreur.Show vbModal
                Unload formerreur
                Exit Do
            End If
        Loop
        If test1 = False Then
                renv(1) = 0
                renv(2) = 0
                renv(3) = 0
        End If
    End If
     
    cherchcomm = renv
     
    End Function
     
    Function cherchcommune(INSEE As Long, crea As Boolean, liste As String) As Variant
     
    Dim restit(2) As String
    Dim a As Integer
    Dim B As Integer
     
    If INSEE = 0 And crea = False Then
        MsgBox "COMMUNE NON SAISI - cherchcommune", vbCritical
        restit(1) = 0
        restit(2) = ""
        cherchcommune = restit
    Else
        If INSEE = 0 Then
            Load formquestlist
     
                formquestlist.boutajout.Visible = False
                If liste = "commune" Then
                    formquestlist.liste.Caption = liste
                Else
                    If liste = "dde" Then formquestlist.liste.Caption = "dept"
                    If liste = "agglo" Then formquestlist.liste.Caption = "agglom"
                End If
                If liste = "commune" Then
                    formquestlist.list.ColumnCount = 2
                    formquestlist.list.ColumnWidths = "100;200"
                Else
                    If liste = "dde" Or liste = "agglo" Then
                        formquestlist.list.ColumnCount = 2
                        formquestlist.list.ColumnWidths = "20;270"
                    Else
                        formquestlist.boutajout.Visible = False
                        formquestlist.list.ColumnCount = 3
                        formquestlist.list.ColumnWidths = "0;150;150"
                    End If
                End If
                formquestlist.VISU.Visible = True
                For a = 4 To 5000
                    If Sheets(liste).Range("a" & a).Value = "" Then Exit For
     
                    formquestlist.list.AddItem Sheets(liste).Range("a" & a).Value
                    formquestlist.list.list(formquestlist.list.ListCount - 1, 1) = Sheets(liste).Range("b" & a).Value
                    If liste = "commune" Or liste = "dde" Or liste = "agglo" Then
                    Else
                        formquestlist.list.list(formquestlist.list.ListCount - 1, 2) = Sheets(liste).Range("c" & a).Value
                    End If
                Next
    'retourmairie1:
            retbox = False
            comptbox = 0
            Do While retbox = False
                formquestlist.Show vbModal
     
                If formquestlist.num.Caption = "" Then
                    Select Case liste
                        Case "commune"
                            MsgBox "VEUILLEZ SELECTIONNER UNE COMMUNE"
                        Case "ca"
                            MsgBox "VEUILLEZ SELECTIONNER UN CHARGE D'AFFAIRES"
                        Case "prestataire"
                            MsgBox "VEUILLEZ SELECTIONNER UN PRESTATAIRE"
                        Case "dde"
                            MsgBox "VEUILLEZ SELECTIONNER UN DEPARTEMENT"
                        Case "agglo"
                            MsgBox "VEUILLEZ SELECTIONNER UNE AGGLOMERATION OU COMMUNAUTE DE COMMUNES"
                    End Select
                    retbox = False
    '                goto retourmairie
                Else
                    retbox = True
                End If
                comptbox = comptbox + 1
                If comptbox = 100 Then End
            Loop
            restit(1) = formquestlist.nom.Caption
            restit(2) = formquestlist.num.Caption
     
            cherchcommune = restit
            Unload formquestlist
     
        Else
            For a = 4 To 1500
                If Sheets(liste).Range("a" & a).Value = INSEE Then
                    restit(1) = Sheets(liste).Range("b" & a).Value
                    restit(2) = INSEE
                    cherchcommune = restit
                    Exit For
                End If
                If Sheets(liste).Range("a" & a).Value = "" Then
                    Load formquestlist
     
                        If liste = "commune" Then
                            formquestlist.list.ColumnCount = 2
                            formquestlist.list.ColumnWidths = "100;200"
                        Else
                            formquestlist.boutajout.Visible = False
                            formquestlist.list.ColumnCount = 3
                            formquestlist.list.ColumnWidths = "0;150;150"
                        End If
                        formquestlist.VISU.Visible = True
                        formquestlist.liste.Caption = liste
                        For B = 4 To 2000
                            If Sheets(liste).Range("a" & B).Value = "" Then Exit For
                            formquestlist.list.AddItem Sheets(liste).Range("a" & B).Value
                            formquestlist.list.list(formquestlist.list.ListCount - 1, 1) = Sheets(liste).Range("b" & B).Value
                            If liste = "commune" Then
                            Else
                                formquestlist.list.list(formquestlist.list.ListCount - 1, 2) = Sheets(liste).Range("c" & a).Value
                            End If
                        Next
    'retourmairie2:
                    retbox = False
                    comptbox = 0
                    Do While retbox = False
                        formquestlist.Show vbModal
     
                        If formquestlist.num.Caption = "" Then
                            Select Case liste
                                Case "commune"
                                    MsgBox "VEUILLEZ SELECTIONNER UNE COMMUNE"
                                Case "ca"
                                    MsgBox "VEUILLEZ SELECTIONNER UN CHARGE D'AFFAIRES"
                                Case "prestataire"
                                    MsgBox "VEUILLEZ SELECTIONNER UN PRESTATAIRE"
                            End Select
     
         '                   GoTo retourmairie2
                        Else
                            retbox = True
                        End If
                        comptbox = comptbox + 1
                        If comptbox = 100 Then End
                    Loop
                    restit(1) = formquestlist.nom.Caption
                    restit(2) = INSEE
                    cherchcommune = restit
                    Unload formquestlist
                    Exit For
                End If
            Next a
        End If
    End If
     
    End Function
     
     
    Function cherchdivers(ligdeb As Integer, FEUIL As String, val1 As Variant, col1 As String, utval2 As Boolean, Optional param As Boolean, Optional val2 As String, Optional col2 As String)
     
    'cette fonction ne renvoie que le numéro de ligne correspondant à la recherche
    'remplir la ligne debut + le nom de la feuille + la colonne de recherche et la valeur recherchée
    'possible de rechercher une seconde valeur dans une autre colonne en remplissant les options
    'param à true le critère sera AND et à false le critère sera OR
    'pour l'utiliser en plusieurs resultat faire tourner en boucle cette fonction en modifiant la ligne debut
    ' ATTENTION SI LA VALEUR RECHERCHER N EST PAS TROUVE LE RESULTAT SERA 0
     
    test1 = False
    test2 = False
    nom1 = val1
     
    chlig1 = ligdeb
    If val1 = "" And Sheets(FEUIL).Range("a" & chlig1).Value = "" Then
        cherchdivers = chlig1
        Exit Function
    End If
    Do While Sheets(FEUIL).Range("a" & chlig1).Value <> ""
        If nom1 = Sheets(FEUIL).Range(col1 & chlig1).Value Then
            test1 = True
        End If
     
        If utval2 = False Then
            test2 = True
        Else
            If val2 = Sheets(FEUIL).Range(col2 & chlig1).Value Then
                If param = False Then
                    test1 = True
                    test2 = True
                Else
                    If test1 = True Then test2 = True
                End If
            End If
        End If
        If test1 = True And test2 = True Then
            cherchdivers = chlig1
            Exit Do
        End If
     
        chlig1 = chlig1 + 1
        If val1 = "" And Sheets(FEUIL).Range("a" & chlig1).Value = "" Then
            cherchdivers = chlig1
            test1 = True
            test2 = True
        End If
        If chlig1 = 10000 Then
            Load formerreur
                formerreur.titre.Caption = "ERREUR BOUCLE"
                formerreur.mess.Caption = "dépassement de capacite dans le programme" & vbCrLf & "CONTACTER LE CONCEPTEUR ET DONNER CE CODE ERREUR :" & vbCrLf & "sortcherchdivers"
            formerreur.Show vbModal
            Unload formerreur
            Exit Do
        End If
    Loop
    If test1 = False Or test2 = False Then cherchdivers = 0
     
    End Function
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    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
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    833
    834
    835
    836
    837
    838
    839
    840
    841
    842
    843
    844
    845
    846
    847
    848
    849
    850
    851
    852
    853
    854
    855
    856
    857
    858
    859
    860
    861
    862
    863
    864
    865
    866
    867
    868
    869
    870
    871
    872
    873
    874
    875
    876
    877
    878
    879
    880
    881
    882
    883
    884
    885
    886
    887
    888
    889
    890
    891
    892
    893
    894
    895
    896
    897
    898
    899
    900
    901
    902
    903
    904
    905
    906
    907
    908
    909
    910
    911
    912
    913
    914
    915
    916
    917
    918
    919
    920
    921
    922
    923
    924
    925
    926
    927
    928
    929
    930
    931
    932
    933
    934
    935
    936
    937
    938
    939
    940
    941
    942
    943
    944
    945
    946
    947
    948
    949
    950
    951
    952
    953
    954
    955
    956
    957
    958
    959
    960
    961
    962
    963
    964
    965
    966
    967
    968
    969
    970
    971
    972
    973
    974
    975
    976
    977
    978
    979
    980
    981
    982
    983
    984
    985
    986
    987
    988
    989
    990
    991
    992
    993
    994
    995
    996
    997
    998
    999
    1000
    1001
    1002
    1003
    1004
    1005
    1006
    1007
    1008
    1009
    1010
    1011
    1012
    1013
    1014
    1015
    1016
    1017
    1018
    1019
    1020
    1021
    1022
    1023
    1024
    1025
    1026
    1027
    1028
    1029
    1030
    1031
    1032
    1033
    1034
    1035
    1036
    1037
    1038
    1039
    1040
    1041
    1042
    1043
    1044
    1045
    1046
    1047
    1048
    1049
    1050
    1051
    1052
    1053
    1054
    1055
    1056
    1057
    1058
    1059
    1060
    1061
    1062
    1063
    1064
    1065
    1066
    1067
    1068
    1069
    1070
    1071
    1072
    1073
    1074
    1075
    1076
    1077
    1078
    1079
    1080
    1081
    1082
    1083
    1084
    1085
    1086
    1087
    1088
    1089
    1090
    1091
    1092
    1093
    1094
    1095
    1096
    1097
    1098
    1099
    1100
    1101
    1102
    1103
    1104
    1105
    1106
    1107
    1108
    1109
    1110
    1111
    1112
    1113
    1114
    1115
    1116
    1117
    1118
    1119
    1120
    1121
    1122
    1123
    1124
    1125
    1126
    1127
    1128
    1129
    1130
    1131
    1132
    1133
    1134
    1135
    1136
    1137
    1138
    1139
    1140
    1141
    1142
    1143
    1144
    1145
    1146
    1147
    1148
    1149
    1150
    1151
    1152
    1153
    1154
    1155
    1156
    1157
    1158
    1159
    1160
    1161
    1162
    1163
    1164
    1165
    1166
    1167
    1168
    1169
    1170
    1171
    1172
    1173
    1174
    1175
    1176
    1177
    1178
    1179
    1180
    1181
    1182
    1183
    1184
    1185
    1186
    1187
    1188
    1189
    1190
    1191
    1192
    1193
    1194
    1195
    1196
    1197
    1198
    1199
    1200
    1201
    1202
    1203
    1204
    1205
    1206
    1207
    1208
    1209
    1210
    1211
    1212
    1213
    1214
    1215
    1216
    1217
    1218
    1219
    1220
    1221
    1222
    1223
    1224
    1225
    1226
    1227
    1228
    1229
    1230
    1231
    1232
    1233
    1234
    1235
    1236
    1237
    1238
    1239
    1240
    1241
    1242
    1243
    1244
    1245
    1246
    1247
    1248
    1249
    1250
    1251
    1252
    1253
    1254
    1255
    1256
    1257
    1258
    1259
    1260
    1261
    1262
    1263
    1264
    1265
    1266
    1267
    1268
    1269
    1270
    1271
    1272
    1273
    1274
    1275
    1276
    1277
    1278
    1279
    1280
    1281
    1282
    1283
    1284
    1285
    1286
    1287
    1288
    1289
    1290
    1291
    1292
    1293
    1294
    1295
    1296
    1297
    1298
    1299
    1300
    1301
    1302
    1303
    1304
    1305
    1306
    1307
    1308
    1309
    1310
    1311
    1312
    1313
    1314
    1315
    1316
    1317
    1318
    1319
    1320
    1321
    1322
    1323
    1324
    1325
    1326
    1327
    1328
    1329
    1330
    1331
    1332
    1333
    1334
    1335
    1336
    1337
    1338
    1339
    1340
    1341
    1342
    1343
    1344
    1345
    1346
    1347
    1348
    1349
    1350
     
    Option Explicit
     
    Dim a As Single
    Dim B As Single
    Dim c As Single
    Dim d As Single
    Dim e As Single
    Dim lig As Integer
    Dim ligmaj As Integer
    Dim ligmaj1 As Single
    Dim ligmaj2 As Single
    Dim ligmaj3 As Single
    Dim ligmaj4 As Single
    Dim ligmaj5 As Single
    Dim ligmaj6 As Single
    Dim ligmaj7 As Integer
    Dim test As Boolean
    Dim test1 As Boolean
    Dim nume As String
    Dim nom As String
    Dim nom1 As String
    Dim nom2 As String
    Dim nom3 As String
    Dim nom4 As String
    Dim nom5 As String
    Dim num As Integer
    Dim num1 As Single
    Dim num2 As Single
    Dim numinsee As Integer
    Dim nmtext As Object
    Dim numan As Date
    Dim retbox As Boolean
    Dim comptbox As Single
     
    Sub ouvperm()
     
    'verifie que les listes ne soient pas vide avant de démarrer
    nom = ""
    num = cherchdiversvide(4, "commune", "a")
    If num = 4 Then nom = "commune"
    num = cherchdiversvide(4, "ca", "a")
    If num = 4 Then If nom = "" Then nom = "chargés d'affaires" Else nom = nom & ", chargés d'affaires"
     
    num = cherchdiversvide(4, "service", "a")
    If num = 4 Then If nom = "" Then nom = "services" Else nom = nom & ", services"
     
    num = cherchdiversvide(4, "agglo", "a")
    If num = 4 Then If nom = "" Then nom = "communautés d'agglomérations" Else nom = nom & ", communautés d'agglomérations"
     
    num = cherchdiversvide(4, "dde", "a")
    If num = 4 Then If nom = "" Then nom = "départements" Else nom = nom & ", départements"
     
    num = cherchdiversvide(4, "prestataire", "a")
    If num = 4 Then If nom = "" Then nom = "prestataires" Else nom = nom & ", prestataires"
    If nom = "" Then
    Else
        Load formerreur
            formerreur.titre.Caption = "CERTAINES LISTES SONT VIDES"
            formerreur.mess.Caption = "Les listes suivantes doivent être complétées avant de démarrer une permission de voirie : " & nom
        formerreur.Show vbModal
        Unload formerreur
        Exit Sub
    End If
    Unload formvuegen
    Load formperm
        formperm.infdate.Visible = False
        formperm.boutenv.Caption = "ENVOYER"
        formperm.boutrel.Visible = False
        numan = Year(Date)
        If Sheets("listperm").Range("c1").Value <> Year(Date) Then
            Sheets("listperm").Range("c1").Value = Year(Date)
            Sheets("listperm").Range("c2").Value = 0
        End If
        num = Sheets("listperm").Range("c2").Value + 1
        nom = Sheets("listperm").Range("c1").Value & "-" & num
        formperm.saisnumperm.Value = nom
        majpageperm "envoie"
    formperm.Show
     
    End Sub
    Sub majformperm(numod As String, modif As Boolean)
     
    'selectionne les feuilles à mettre à jour
     
    If modif = True Then
        For ligmaj1 = 1 To 5
            If ligmaj1 <> 1 Then
                formperm.Controls("Framadres" & ligmaj1).Visible = False
                formperm.Controls("Framdat" & ligmaj1).Visible = False
                formperm.Controls("Framterb" & ligmaj1).Visible = False
                formperm.Controls("Framterr" & ligmaj1).Visible = False
            End If
            formperm.Controls("Labadres" & ligmaj1 & "2").Visible = True
            formperm.Controls("saisadres" & ligmaj1 & "2").Visible = True
            formperm.Controls("Labadres" & ligmaj1 & "3").Visible = True
            formperm.Controls("saisadres" & ligmaj1 & "3").Visible = True
            formperm.Controls("Labdat" & ligmaj1 & "3").Visible = False
            formperm.Controls("saisdat" & ligmaj1 & "3").Visible = False
            formperm.Controls("boutdat" & ligmaj1 & "3").Visible = False
            formperm.Controls("saisdat" & ligmaj1 & "2").Visible = False
            formperm.Controls("Labdat" & ligmaj1 & "2b").Visible = False
            formperm.Controls("Labdat" & ligmaj1 & "2").Visible = False
        Next ligmaj1
        formperm.Labterrt.Visible = True
        formperm.Labterrl.Visible = True
        formperm.Labterrf.Visible = True
        formperm.Labterr1t.Visible = True
        For ligmaj2 = 1 To 5
            For ligmaj1 = 1 To 6
                formperm.Controls("saisterr" & ligmaj2 & ligmaj1).Visible = True
                formperm.Controls("Labterr" & ligmaj2 & ligmaj1).Visible = True
            Next ligmaj1
            formperm.Controls("Labterr" & ligmaj2 & "v").Caption = "SOUS VOIRIE :"
        Next ligmaj2
        formperm.visadres.Value = False
        formperm.viscirc.Value = False
        formperm.visdat.Value = False
        formperm.visprec.Visible = False
        formperm.visterb.Value = False
        formperm.visterr.Value = False
        formperm.visurba.Value = False
        formperm.visfouil.Value = False
        formperm.viscoupur.Value = False
        formperm.visdict.Value = False
        formperm.visint.Value = False
        formperm.vishorair.Value = False
     
        formperm.typadres.Caption = ""
        formperm.typdat.Caption = ""
        formperm.typterb.Caption = ""
        formperm.typterr.Caption = ""
        formperm.typcirc.Caption = ""
        formperm.typcoupur.Caption = ""
        formperm.typdict.Caption = ""
        formperm.typfouil.Caption = ""
        formperm.typhorair.Caption = ""
        formperm.typint.Caption = ""
        formperm.typrec.Caption = ""
        formperm.typurba.Caption = ""
    End If
     
     
    'recherche de la ligne dans modele et remplit les éléments généraux sur le modèle
     
    ligmaj = cherchdivers(5, "modele", numod, "a", False)
    formperm.saismodelnum.Caption = Sheets("modele").Range("a" & ligmaj).Value
    formperm.saismodel.Caption = Sheets("modele").Range("b" & ligmaj).Value
    formperm.saismodelig.Caption = ligmaj
     
     
    'MISE EN FORME DE LA FEUILLE LISTE ADRESSE
    formperm.typadres.Caption = Sheets("modele").Range("e" & ligmaj).Value
    Select Case Sheets("modele").Range("e" & ligmaj).Value
     
        Case "simplnum"
            formperm.visadres.Value = True
            formperm.Labadres12.Visible = False
            formperm.saisadres12.Visible = False
            formperm.Labadres13.Visible = True
            formperm.saisadres13.Visible = True
            formperm.Framadres1.Visible = True
            For ligmaj2 = 2 To 5
                formperm.Controls("Framadres" & ligmaj2).Visible = False
            Next ligmaj2
     
        Case "simplnums"
            formperm.visadres.Value = True
            formperm.Labadres12.Visible = True
            formperm.saisadres12.Visible = True
            formperm.Labadres13.Visible = False
            formperm.saisadres13.Visible = False
            formperm.Framadres1.Visible = True
            For ligmaj2 = 2 To 5
                formperm.Controls("Framadres" & ligmaj2).Visible = False
            Next ligmaj2
     
        Case "multinum"
            formperm.visadres.Value = True
            formperm.Labadres12.Visible = False
            formperm.saisadres12.Visible = False
            formperm.Labadres13.Visible = True
            formperm.saisadres13.Visible = True
            ligmaj1 = Sheets("modele").Range("f" & ligmaj).Value
            For ligmaj2 = 2 To 5
                If ligmaj2 <= ligmaj1 Then
                    formperm.Controls("Framadres" & ligmaj2).Visible = True
                    formperm.Controls("Labadres" & ligmaj2 & "2").Visible = False
                    formperm.Controls("saisadres" & ligmaj2 & "2").Visible = False
                    formperm.Controls("Labadres" & ligmaj2 & "3").Visible = True
                    formperm.Controls("saisadres" & ligmaj2 & "3").Visible = True
                Else
                    formperm.Controls("Framadres" & ligmaj2).Visible = False
                End If
            Next ligmaj2
     
        Case "multinums"
            formperm.visadres.Value = True
            formperm.Labadres12.Visible = True
            formperm.saisadres12.Visible = True
            formperm.Labadres13.Visible = False
            formperm.saisadres13.Visible = False
            ligmaj1 = Sheets("modele").Range("f" & ligmaj).Value
            For ligmaj2 = 2 To 5
                If ligmaj2 <= ligmaj1 Then
                    formperm.Controls("Framadres" & ligmaj2).Visible = True
                    formperm.Controls("Labadres" & ligmaj2 & "2").Visible = True
                    formperm.Controls("saisadres" & ligmaj2 & "2").Visible = True
                    formperm.Controls("Labadres" & ligmaj2 & "3").Visible = False
                    formperm.Controls("saisadres" & ligmaj2 & "3").Visible = False
                Else
                    formperm.Controls("Framadres" & ligmaj2).Visible = False
                End If
            Next ligmaj2
     
        Case "simplnumsanc"
            formperm.visadres.Value = True
            formperm.visadres.Value = True
            formperm.Labadres12.Visible = False
            formperm.saisadres12.Visible = False
            formperm.Labadres13.Visible = True
            formperm.saisadres13.Visible = True
            formperm.Framadres1.Visible = True
            For ligmaj2 = 2 To 5
                formperm.Controls("Framadres" & ligmaj2).Visible = False
            Next ligmaj2
     
        Case "multinumsanc"
            formperm.visadres.Value = True
            formperm.Labadres12.Visible = False
            formperm.saisadres12.Visible = False
            formperm.Labadres13.Visible = True
            formperm.saisadres13.Visible = True
            ligmaj1 = Sheets("modele").Range("f" & ligmaj).Value
            For ligmaj2 = 2 To 5
                If ligmaj2 <= ligmaj1 Then
                    formperm.Controls("Framadres" & ligmaj2).Visible = True
                    formperm.Controls("Labadres" & ligmaj2 & "2").Visible = False
                    formperm.Controls("saisadres" & ligmaj2 & "2").Visible = False
                    formperm.Controls("Labadres" & ligmaj2 & "3").Visible = True
                    formperm.Controls("saisadres" & ligmaj2 & "3").Visible = True
                Else
                    formperm.Controls("Framadres" & ligmaj2).Visible = False
                End If
            Next ligmaj2
     
        Case "simplnumssanc"
            formperm.visadres.Value = True
            formperm.Labadres12.Visible = True
            formperm.saisadres12.Visible = True
            formperm.Labadres13.Visible = False
            formperm.saisadres13.Visible = False
            formperm.Framadres1.Visible = True
            For ligmaj2 = 2 To 5
                formperm.Controls("Framadres" & ligmaj2).Visible = False
            Next ligmaj2
     
        Case "multinumssanc"
            formperm.visadres.Value = True
            formperm.Labadres12.Visible = True
            formperm.saisadres12.Visible = True
            formperm.Labadres13.Visible = False
            formperm.saisadres13.Visible = False
            ligmaj1 = Sheets("modele").Range("f" & ligmaj).Value
            For ligmaj2 = 2 To 5
                If ligmaj2 <= ligmaj1 Then
                    formperm.Controls("Framadres" & ligmaj2).Visible = True
                    formperm.Controls("Labadres" & ligmaj2 & "2").Visible = True
                    formperm.Controls("saisadres" & ligmaj2 & "2").Visible = True
                    formperm.Controls("Labadres" & ligmaj2 & "3").Visible = False
                    formperm.Controls("saisadres" & ligmaj2 & "3").Visible = False
                Else
                    formperm.Controls("Framadres" & ligmaj2).Visible = False
                End If
            Next ligmaj2
     
    End Select
     
     
    'MISE EN FORME DES FEUILLES TERRASSEMENTS
     
    Select Case Sheets("modele").Range("g" & ligmaj).Value
     
        Case "terrtype"
            formperm.visterr.Value = True
            formperm.typterr.Caption = Sheets("modele").Range("g" & ligmaj).Value
            formperm.visterb.Value = False
            formperm.Labterr1v.Caption = "LONGUEUR"
            formperm.Labterrl.Caption = "SOUS VOIRIE"
            formperm.Labterrt.Caption = "SOUS TROTTOIR"
            formperm.Labterr1t.Visible = False
            For ligmaj2 = 1 To 6
                If ligmaj2 < 4 Then
                    formperm.Controls("saisterr1" & a).Visible = True
                    formperm.Controls("Labterr1" & a).Visible = True
                Else
                    formperm.Controls("saisterr1" & a).Visible = False
                    formperm.Controls("Labterr1" & a).Visible = False
                End If
            Next ligmaj2
            For ligmaj2 = 1 To 5
                If ligmaj2 = 1 Then
                    formperm.Controls("Framterr" & ligmaj2).Visible = False
                Else
                    formperm.Controls("Framterr" & ligmaj2).Visible = False
                End If
            Next
     
        Case "terrmultitype"
            formperm.visterr.Value = True
            formperm.typterr.Caption = Sheets("modele").Range("g" & ligmaj).Value
            formperm.visterb.Value = False
            formperm.Labterrl.Caption = "SOUS VOIRIE :"
            formperm.Labterrt.Caption = "SOUS TROTTOIR :"
            For ligmaj1 = 1 To 5
                If ligmaj2 <= Sheets("modele").Range("h" & ligmaj).Value Then
                    formperm.Controls("Labterr" & ligmaj1 & "v").Caption = "LONGUEUR"
                    formperm.Controls("Labterr" & ligmaj1 & "t").Visible = False
                    formperm.Controls("Framterr" & ligmaj2).Visible = True
                    For ligmaj2 = 2 To 6
                        If ligmaj2 < 4 Then
                            formperm.Controls("saisterr" & ligmaj1 & ligmaj2).Visible = True
                            formperm.Controls("Labterr1" & ligmaj1 & ligmaj2).Visible = True
                        Else
                            formperm.Controls("saisterr1" & ligmaj1 & ligmaj2).Visible = False
                            formperm.Controls("Labterr1" & ligmaj1 & ligmaj2).Visible = False
                        End If
                    Next ligmaj2
                Else
                    formperm.Controls("Framterr" & ligmaj2).Visible = False
                End If
            Next ligmaj1
     
        Case "terrsimpune"
            formperm.visterr.Value = True
            formperm.typterr.Caption = Sheets("modele").Range("g" & ligmaj).Value
            formperm.visterb.Value = False
            formperm.Labterrt.Visible = False
            formperm.Labterrl.Visible = False
            formperm.Labterrf.Visible = False
            formperm.Labterr1t.Visible = False
            For ligmaj1 = 1 To 6
                If ligmaj1 = 1 Then
                    formperm.Controls("saisterr1" & ligmaj1).Visible = True
                    formperm.Controls("Labterr1" & ligmaj1).Visible = True
                Else
                    formperm.Controls("saisterr1" & ligmaj1).Visible = False
                    formperm.Controls("Labterr1" & ligmaj1).Visible = False
                End If
            Next ligmaj1
            For ligmaj2 = 1 To 5
                If ligmaj2 = 1 Then
                    formperm.Controls("Framterr" & ligmaj2).Visible = True
                Else
                    formperm.Controls("Framterr" & ligmaj2).Visible = False
                End If
            Next
            formperm.Labterr1v.Caption = "LONGUEUR :"
     
        Case "terrmultiune"
            formperm.visterr.Value = True
            formperm.typterr.Caption = Sheets("modele").Range("g" & ligmaj).Value
            formperm.visterb.Value = False
            formperm.Labterrt.Visible = False
            formperm.Labterrl.Visible = False
            formperm.Labterrf.Visible = False
            For ligmaj2 = 1 To 5
                If ligmaj2 <= Sheets("modele").Range("h" & ligmaj).Value Then ' Or ligmaj2 < Sheets("modele").Range("h" & ligmaj).Value Then
                    formperm.Controls("Framterr" & ligmaj2).Visible = True
                    For ligmaj1 = 1 To 6
                        If ligmaj1 = 1 Then
                            formperm.Controls("saisterr" & ligmaj2 & ligmaj1).Visible = True
                            formperm.Controls("Labterr" & ligmaj2 & ligmaj1).Visible = True
                        Else
                            formperm.Controls("saisterr" & ligmaj2 & ligmaj1).Visible = False
                            formperm.Controls("Labterr" & ligmaj2 & ligmaj1).Visible = False
                        End If
                    Next ligmaj1
                    formperm.Controls("Labterr" & ligmaj2 & "t").Visible = False
                    formperm.Controls("Labterr" & ligmaj2 & "v").Caption = "LONGUEUR :"
                Else
                    formperm.Controls("Framterr" & ligmaj2).Visible = False
                End If
            Next ligmaj2
     
        Case "terrsimp"
            formperm.visterr.Value = True
            formperm.typterr.Caption = Sheets("modele").Range("g" & ligmaj).Value
            formperm.visterb.Value = False
            formperm.Labterrt.Visible = True
            formperm.Labterrl.Visible = True
            formperm.Labterrf.Visible = True
            formperm.Labterrl.Caption = "LONGITUDINAL :"
            formperm.Labterrt.Caption = "TRANSVERSAL :"
            formperm.Labterr1t.Visible = True
            formperm.Labterr1v.Caption = "SOUS VOIRIE :"
            For ligmaj2 = 1 To 5
                If ligmaj2 = 1 Then
                    formperm.Controls("Framterr" & ligmaj2).Visible = True
                Else
                    formperm.Controls("Framterr" & ligmaj2).Visible = False
                End If
            Next
            For ligmaj1 = 1 To 6
                formperm.Controls("saisterr1" & ligmaj1).Visible = True
                formperm.Controls("Labterr1" & ligmaj1).Visible = True
            Next ligmaj1
     
        Case "terrmulti"
            formperm.visterr.Value = True
            formperm.typterr.Caption = Sheets("modele").Range("g" & ligmaj).Value
            formperm.visterb.Value = False
            formperm.Labterrt.Visible = True
            formperm.Labterrl.Visible = True
            formperm.Labterrf.Visible = True
            formperm.Labterr1t.Visible = True
            formperm.Labterrl.Caption = "LONGITUDINAL :"
            formperm.Labterrt.Caption = "TRANSVERSAL :"
            For ligmaj2 = 1 To 5
                If ligmaj2 <= Sheets("modele").Range("h" & ligmaj).Value Then
                    formperm.Controls("Framterr" & ligmaj2).Visible = True
                    formperm.Controls("Labterr" & ligmaj2 & "v").Caption = "SOUS VOIRIE :"
                    formperm.Controls("Labterr" & ligmaj2 & "t").Visible = True
                    For ligmaj1 = 1 To 6
                        formperm.Controls("saisterr" & ligmaj2 & ligmaj1).Visible = True
                        formperm.Controls("Labterr" & ligmaj2 & ligmaj1).Visible = True
                    Next ligmaj1
                Else
                    formperm.Controls("Framterr" & ligmaj2).Visible = False
                End If
            Next ligmaj2
     
        Case "terbsimp"
            charglistmaform "revet", 1, numod
            charglistmaform "encomb", 1, numod
            formperm.visterr.Value = False
            formperm.visterb.Value = True
            formperm.typterb.Caption = Sheets("modele").Range("g" & ligmaj).Value
            For ligmaj1 = 1 To 6
                'masque les frames
                If ligmaj1 = 1 Then
                    formperm.Controls("Framterb" & ligmaj1).Visible = True
                Else
                    If ligmaj1 = 6 Then Else formperm.Controls("Framterb" & ligmaj1).Visible = False
                End If
                'masque certains champs
                If ligmaj1 = 1 Or ligmaj1 = 2 Or ligmaj1 = 3 Or ligmaj1 = 4 Or ligmaj1 = 5 Then
                    formperm.Controls("Labterb1" & ligmaj1).Visible = True
                    formperm.Controls("saisterb1" & ligmaj1).Visible = True
                    If ligmaj1 = 5 Then
                        formperm.Controls("Labterb1" & ligmaj1 & "b").Visible = True
                   '     formperm.Controls("Labterb1" & ligmaj1 & "c").Visible = True
                    End If
                Else
                    formperm.Controls("Labterb1" & ligmaj1).Visible = False
                    formperm.Controls("saisterb1" & ligmaj1).Visible = False
                    If ligmaj1 = 4 Then
                        formperm.Controls("Labterb1" & ligmaj1 & "b").Visible = False
                   '     formperm.Controls("Labterb1" & ligmaj1 & "c").Visible = False
                    End If
     
                End If
            Next ligmaj1
     
        Case "terbmulti"
            formperm.visterr.Value = False
            formperm.visterb.Value = True
            formperm.typterb.Caption = Sheets("modele").Range("g" & ligmaj).Value
            For ligmaj1 = 1 To 5
                If ligmaj1 <= Sheets("modele").Range("h" & ligmaj).Value Then
                    charglistmaform "revet", ligmaj1, numod
                    charglistmaform "encomb", ligmaj1, numod
                    formperm.Controls("Framterb" & ligmaj1).Visible = True
                    For ligmaj2 = 1 To 6
                        'masque certains champs
                        If ligmaj2 = 1 Or ligmaj2 = 2 Or ligmaj2 = 3 Or ligmaj2 = 4 Or ligmaj2 = 5 Then
                            formperm.Controls("Labterb" & ligmaj1 & ligmaj2).Visible = True
                            formperm.Controls("saisterb" & ligmaj1 & ligmaj2).Visible = True
                            If ligmaj2 = 5 Then
                                formperm.Controls("Labterb" & ligmaj1 & ligmaj2 & "b").Visible = True
                          '      formperm.Controls("Labterb" & ligmaj1 & ligmaj2 & "c").Visible = True
                            End If
                        Else
                            formperm.Controls("Labterb" & ligmaj1 & ligmaj2).Visible = False
                            formperm.Controls("saisterb" & ligmaj1 & ligmaj2).Visible = False
                            If ligmaj2 = 4 Then
                                formperm.Controls("Labterb" & ligmaj1 & ligmaj2 & "b").Visible = False
                       '         formperm.Controls("Labterb" & ligmaj1 & ligmaj2 & "c").Visible = False
                            End If
                        End If
                    Next ligmaj2
                Else
                    formperm.Controls("Framterb" & ligmaj1).Visible = False
                End If
            Next ligmaj1
     
        Case "terbencslarg"
                charglistmaform "encomb", 1, numod
                charglistmaform "techniq", 1, numod
                formperm.visterr.Value = False
                formperm.visterb.Value = True
                formperm.typterb.Caption = Sheets("modele").Range("g" & ligmaj).Value
                For ligmaj1 = 1 To 6
                    'masque les frames
                    If ligmaj1 = 1 Then
                        formperm.Controls("Framterb" & ligmaj1).Visible = True
                    Else
                        If ligmaj1 = 6 Then Else formperm.Controls("Framterb" & ligmaj1).Visible = False
                    End If
                    'masque certains champs
                    If ligmaj1 = 1 Or ligmaj1 = 3 Or ligmaj1 = 6 Then
                        formperm.Controls("Labterb1" & ligmaj1).Visible = True
                        formperm.Controls("saisterb1" & ligmaj1).Visible = True
                    Else
                        formperm.Controls("Labterb1" & ligmaj1).Visible = False
                        formperm.Controls("saisterb1" & ligmaj1).Visible = False
                        If ligmaj1 = 4 Or ligmaj1 = 5 Then
                            formperm.Controls("Labterb1" & ligmaj1 & "b").Visible = False
                       '     formperm.Controls("Labterb1" & ligmaj1 & "c").Visible = False
                        End If
                    End If
                Next ligmaj1
     
        Case "terbmultiencslarg"
                formperm.visterr.Value = False
                formperm.visterb.Value = True
                formperm.typterb.Caption = Sheets("modele").Range("g" & ligmaj).Value
                For ligmaj1 = 1 To 5
                    If ligmaj1 <= Sheets("modele").Range("h" & ligmaj).Value Then
                        charglistmaform "encomb", ligmaj1, numod
                        charglistmaform "techniq", ligmaj1, numod
                        formperm.Controls("Framterb" & ligmaj1).Visible = True
                        For ligmaj2 = 1 To 6
                            'masque certains champs
                            If ligmaj2 = 2 Or ligmaj2 = 4 Or ligmaj2 = 5 Then
                                formperm.Controls("Labterb" & ligmaj1 & ligmaj2).Visible = False
                                formperm.Controls("saisterb" & ligmaj1 & ligmaj2).Visible = False
                                If ligmaj1 = 4 Or ligmaj1 = 5 Then
                                    formperm.Controls("Labterb" & ligmaj1 & ligmaj2 & "b").Visible = False
                              '      formperm.Controls("Labterb" & ligmaj1 & ligmaj2 & "c").Visible = False
                                End If
                            Else
                                formperm.Controls("Labterb" & ligmaj1 & ligmaj2).Visible = True
                                formperm.Controls("saisterb" & ligmaj1 & ligmaj2).Visible = True
                            End If
                        Next ligmaj2
                    Else
                        'masque les frames
                        formperm.Controls("Framterb" & ligmaj1).Visible = False
                    End If
                Next ligmaj1
     
        Case "terbencalarg"
                charglistmaform "encomb", 1, numod
                charglistmaform "techniq", 1, numod
                formperm.visterr.Value = False
                formperm.visterb.Value = True
                formperm.typterb.Caption = Sheets("modele").Range("g" & ligmaj).Value
                For ligmaj1 = 1 To 6
                    'masque les frames
                    If ligmaj1 = 1 Then
                        formperm.Controls("Framterb" & ligmaj1).Visible = True
                    Else
                        If ligmaj1 = 6 Then Else formperm.Controls("Framterb" & ligmaj1).Visible = False
                    End If
                    'masque certains champs
                    If ligmaj1 = 2 Or ligmaj1 = 5 Then
                        formperm.Controls("Labterb1" & ligmaj1).Visible = False
                        formperm.Controls("saisterb1" & ligmaj1).Visible = False
                        If ligmaj1 = 5 Then
                            formperm.Controls("Labterb1" & ligmaj1 & "b").Visible = False
                        '    formperm.Controls("Labterb1" & ligmaj1 & "c").Visible = False
                        End If
                    Else
                        formperm.Controls("Labterb1" & ligmaj1).Visible = True
                        formperm.Controls("saisterb1" & ligmaj1).Visible = True
                        If ligmaj1 = 4 Then
                            formperm.Controls("Labterb1" & ligmaj1 & "b").Visible = True
                    '        formperm.Controls("Labterb1" & ligmaj1 & "c").Visible = True
                        End If
                    End If
                Next ligmaj1
     
        Case "terbmultiencalarg"
            formperm.visterr.Value = False
            formperm.visterb.Value = True
            formperm.typterb.Caption = Sheets("modele").Range("g" & ligmaj).Value
            For ligmaj1 = 1 To 5
                If ligmaj1 <= Sheets("modele").Range("h" & ligmaj).Value Then
                    charglistmaform "encomb", ligmaj1, numod
                    charglistmaform "techniq", ligmaj1, numod
                    formperm.Controls("Framterb" & ligmaj1).Visible = True
                    For ligmaj2 = 1 To 6
                        'masque certains champs
                        If ligmaj2 = 2 Or ligmaj2 = 5 Then
                            formperm.Controls("Labterb" & ligmaj1 & ligmaj2).Visible = False
                            formperm.Controls("saisterb" & ligmaj1 & ligmaj2).Visible = False
                            If ligmaj1 = 5 Then
                                formperm.Controls("Labterb" & ligmaj1 & ligmaj2 & "b").Visible = False
                          '      formperm.Controls("Labterb" & ligmaj1 & ligmaj2 & "c").Visible = False
                            End If
                        Else
                            formperm.Controls("Labterb" & ligmaj1 & ligmaj2).Visible = True
                            formperm.Controls("saisterb" & ligmaj1 & ligmaj2).Visible = True
                            If ligmaj1 = 4 Then
                                formperm.Controls("Labterb" & ligmaj1 & ligmaj2 & "b").Visible = True
                           '     formperm.Controls("Labterb" & ligmaj1 & ligmaj2 & "c").Visible = True
                            End If
                        End If
                    Next ligmaj2
                Else
                    'masque les frames
                    formperm.Controls("Framterb" & ligmaj1).Visible = False
                End If
            Next ligmaj1
    End Select
     
    'MISE EN FORME DE LA FEUILLE DATE
    formperm.typdat.Caption = Sheets("modele").Range("i" & ligmaj).Value
    formperm.visdat.Value = True
    Select Case Sheets("modele").Range("i" & ligmaj).Value
     
        Case "simpdelai"
            formperm.Labdat13.Visible = False
            formperm.saisdat13.Visible = False
            formperm.boutdat13.Visible = False
            formperm.saisdat12.Visible = True
            formperm.saisdat12.Locked = False
            formperm.Labdat12b.Visible = True
            formperm.Labdat12.Visible = True
            formperm.Framdat1.Visible = True
            For ligmaj1 = 2 To 5
                formperm.Controls("Framdat" & ligmaj1).Visible = False
            Next
     
        Case "simpdate"
            formperm.saisdat12.Visible = False
            formperm.Labdat12b.Visible = False
            formperm.Labdat12.Visible = False
            formperm.Labdat13.Visible = True
            formperm.saisdat13.Visible = True
            formperm.boutdat13.Visible = True
            formperm.Framdat1.Visible = True
            For ligmaj1 = 2 To 5
                formperm.Controls("Framdat" & ligmaj1).Visible = False
            Next
     
        Case "simples2"
            formperm.saisdat12.Visible = True
            formperm.saisdat12.Locked = True
            formperm.Labdat12b.Visible = True
            formperm.Labdat12.Visible = True
            formperm.Labdat13.Visible = True
            formperm.saisdat13.Visible = True
            formperm.boutdat13.Visible = True
            formperm.Framdat1.Visible = True
            For ligmaj1 = 2 To 5
                formperm.Controls("Framdat" & ligmaj1).Visible = False
            Next
     
        Case "multidelai"
            For ligmaj1 = 1 To 5
                If ligmaj1 <= Sheets("modele").Range("j" & ligmaj).Value Then
                    If ligmaj1 = 1 Then Else formperm.Controls("Framdat" & ligmaj1).Visible = True
                    formperm.Controls("Labdat" & ligmaj1 & "3").Visible = False
                    formperm.Controls("saisdat" & ligmaj1 & "3").Visible = False
                    formperm.Controls("boutdat" & ligmaj1 & "3").Visible = False
                    formperm.Controls("Labdat" & ligmaj1 & "2").Visible = True
                    formperm.Controls("saisdat" & ligmaj1 & "2").Visible = True
                    formperm.Controls("saisdat" & ligmaj & "2").Locked = False
                    formperm.Controls("boutdat" & ligmaj1 & "1").Visible = True
                    formperm.Controls("Framdat" & ligmaj1).Visible = True
                Else
                    If ligmaj1 = 1 Then Else formperm.Controls("Framdat" & ligmaj1).Visible = False
                End If
            Next ligmaj1
     
        Case "multidate"
            For ligmaj1 = 1 To 5
                If ligmaj1 <= Sheets("modele").Range("j" & ligmaj).Value Then
                    If ligmaj1 = 1 Then Else formperm.Controls("Framdat" & ligmaj1).Visible = True
                    formperm.Controls("saisdat" & ligmaj1 & "2").Visible = False
                    formperm.Controls("Labdat" & ligmaj1 & "2b").Visible = False
                    formperm.Controls("Labdat" & ligmaj1 & "2").Visible = False
                    formperm.Controls("Labdat" & ligmaj1 & "3").Visible = True
                    formperm.Controls("saisdat" & ligmaj1 & "3").Visible = True
                    formperm.Controls("boutdat" & ligmaj1 & "3").Visible = True
                Else
                    formperm.Controls("Framdat" & ligmaj1).Visible = False
                End If
            Next ligmaj1
     
        Case "multiles2"
            For ligmaj1 = 1 To 5
                If ligmaj1 <= Sheets("modele").Range("j" & ligmaj).Value Then
                    If ligmaj1 = 1 Then Else formperm.Controls("Framdat" & ligmaj1).Visible = True
                    formperm.Controls("saisdat" & ligmaj1 & "2").Visible = True
                    formperm.Controls("saisdat" & ligmaj1 & "2").Locked = True
                    formperm.Controls("Labdat" & ligmaj1 & "2b").Visible = True
                    formperm.Controls("Labdat" & ligmaj1 & "2").Visible = True
                    formperm.Controls("Labdat" & ligmaj1 & "3").Visible = True
                    formperm.Controls("saisdat" & ligmaj1 & "3").Visible = True
                    formperm.Controls("boutdat" & ligmaj1 & "3").Visible = True
                Else
                    formperm.Controls("Framdat" & ligmaj1).Visible = False
                End If
            Next ligmaj1
     
    End Select
     
     
    'MISE EN FORME PRECISION ADRESSAGE
     
    formperm.typrec.Caption = Sheets("modele").Range("k" & ligmaj).Value
    Select Case Sheets("modele").Range("k" & ligmaj).Value
        Case "numrte"
            formperm.visprec.Value = True
            formperm.Framprec1.Visible = True
            formperm.Framprec2.Visible = False
     
        Case "situa"
            formperm.visprec.Value = True
            formperm.Framprec1.Visible = False
            formperm.Framprec2.Visible = True
     
        Case "les2"
            formperm.visprec.Value = True
            formperm.Framprec1.Visible = True
            formperm.Framprec2.Visible = True
     
        Case "non"
            formperm.visprec.Value = False
    End Select
     
     
    'MISE EN FORME PRECISION URBANISME
     
    formperm.typurba.Caption = Sheets("modele").Range("l" & ligmaj).Value
    Select Case Sheets("modele").Range("l" & ligmaj).Value
     
        Case "numurba"
            formperm.visurba.Value = True
            formperm.Laburba.Visible = False
            formperm.Laburba1.Visible = True
            formperm.saisurba1.Visible = True
            formperm.Laburba2.Visible = False
            formperm.saisurba2.Visible = False
            formperm.Laburba3.Visible = False
            formperm.saisurba3.Visible = False
            formperm.Laburba4.Visible = False
            formperm.saisurba4.Visible = False
     
        Case "non"
            formperm.visurba.Value = False
     
        Case "parc"
            formperm.visurba.Value = True
            formperm.Laburba.Visible = True
            formperm.Laburba1.Visible = False
            formperm.saisurba1.Visible = False
            formperm.Laburba2.Visible = True
            formperm.saisurba2.Visible = True
            formperm.Laburba3.Visible = True
            formperm.saisurba3.Visible = True
            formperm.Laburba4.Visible = True
            formperm.saisurba4.Visible = True
     
        Case "les2"
            formperm.visurba.Value = True
            formperm.Laburba.Visible = True
            formperm.Laburba1.Visible = True
            formperm.saisurba1.Visible = True
            formperm.Laburba2.Visible = True
            formperm.saisurba2.Visible = True
            formperm.Laburba3.Visible = True
            formperm.saisurba3.Visible = True
            formperm.Laburba4.Visible = True
            formperm.saisurba4.Visible = True
     
    End Select
     
     
    'MISE EN FORME ARRETE CIRCULATION
     
    formperm.typcirc.Caption = Sheets("modele").Range("m" & ligmaj).Value
    Select Case Sheets("modele").Range("m" & ligmaj).Value
     
        Case "ouisans"
            formperm.Framcircoch.Visible = True
            formperm.Framcircsais.Visible = False
            formperm.viscirc.Value = True
            formperm.saiscirc4.Visible = False
            formperm.saiscirc7.Visible = False
            formperm.saiscirc8.Visible = False
            formperm.saiscirc9.Visible = False
     
        Case "ouirte"
            formperm.Framcircoch.Visible = True
            formperm.Framcircsais.Visible = False
            formperm.viscirc.Value = True
            formperm.saiscirc4.Visible = True
            formperm.saiscirc7.Visible = False
            formperm.saiscirc8.Visible = False
            formperm.saiscirc9.Visible = False
     
        Case "non"
            formperm.viscirc.Value = False
     
        Case "ouilist"
            formperm.viscirc.Value = True
            charglistmaform "circul", 1, numod
            formperm.Framcircoch.Visible = False
            formperm.Framcircsais.Visible = True
            formperm.saiscirc7.Visible = False
            formperm.saiscirc8.Visible = False
            formperm.saiscirc9.Visible = False
     
        Case "ouirtm"
            formperm.Framcircoch.Visible = True
            formperm.Framcircsais.Visible = False
            formperm.viscirc.Value = True
            formperm.saiscirc4.Visible = False
            formperm.saiscirc7.Visible = True
            formperm.saiscirc8.Visible = False
            formperm.saiscirc9.Visible = False
     
        Case "ouiaut"
            formperm.Framcircoch.Visible = True
            formperm.Framcircsais.Visible = False
            formperm.viscirc.Value = True
            formperm.saiscirc4.Visible = False
            formperm.saiscirc7.Visible = False
            formperm.saiscirc8.Visible = True
            formperm.saiscirc9.Visible = False
     
        Case "ouirtem"
            formperm.Framcircoch.Visible = True
            formperm.Framcircsais.Visible = False
            formperm.viscirc.Value = True
            formperm.saiscirc4.Visible = True
            formperm.saiscirc7.Visible = True
            formperm.saiscirc8.Visible = False
            formperm.saiscirc9.Visible = False
     
        Case "ouirteaut"
            formperm.Framcircoch.Visible = True
            formperm.Framcircsais.Visible = False
            formperm.viscirc.Value = True
            formperm.saiscirc4.Visible = True
            formperm.saiscirc7.Visible = False
            formperm.saiscirc8.Visible = True
            formperm.saiscirc9.Visible = False
     
        Case "ouirtmaut"
            formperm.Framcircoch.Visible = True
            formperm.Framcircsais.Visible = False
            formperm.viscirc.Value = True
            formperm.saiscirc4.Visible = False
            formperm.saiscirc7.Visible = True
            formperm.saiscirc8.Visible = True
            formperm.saiscirc9.Visible = False
     
        Case "ouitous"
            formperm.Framcircoch.Visible = True
            formperm.Framcircsais.Visible = False
            formperm.viscirc.Value = True
            formperm.saiscirc4.Visible = True
            formperm.saiscirc7.Visible = True
            formperm.saiscirc8.Visible = True
            formperm.saiscirc9.Visible = False
     
    End Select
     
    'MISE EN FORME TYPE DE TRAVAUX
     
    Select Case Sheets("modele").Range("n" & ligmaj).Value
     
        Case "sitypdif"
            formperm.visint.Value = True
            formperm.typint.Caption = "sitypdif"
            formperm.Frame26.Visible = True
     
        Case "sityp1"
            formperm.Frame26.Visible = True
            formperm.visint.Value = True
            formperm.typint.Caption = "sityp1"
     
        Case "sitypsais"
            formperm.Frame26.Visible = True
            formperm.visint.Value = True
            formperm.typint.Caption = "sitypsais"
     
        Case "non"
            formperm.Frame26.Visible = False
            formperm.visint.Value = False
            formperm.typint.Caption = "non"
     
    End Select
     
    'MISE EN FORME FOUILLE
    Select Case Sheets("modele").Range("u" & ligmaj).Value
        Case "non"
            formperm.visfouil.Value = False
            formperm.typfouil.Caption = "non"
     
        Case "oui1f"
            formperm.visfouil.Value = True
            formperm.typfouil.Caption = "oui1f"
            charglistmaform "fencomb", 1, numod
            charglistmaform "ftechniq", 1, numod
            For ligmaj1 = 1 To 5
                If ligmaj1 = 1 Then
                    formperm.Controls("framfouil" & ligmaj1).Visible = True
                Else
                    formperm.Controls("framfouil" & ligmaj1).Visible = False
                End If
            Next ligmaj1
     
        Case "ouimulti"
            formperm.visfouil.Value = True
            formperm.typfouil.Caption = "ouimulti"
            For ligmaj1 = 1 To 5
                If ligmaj1 = 1 Then
                    formperm.Controls("framfouil" & ligmaj1).Visible = True
                    charglistmaform "fencomb", ligmaj1, numod
                    charglistmaform "ftechniq", ligmaj1, numod
                Else
                    If ligmaj1 <= Sheets("modele").Range("v" & ligmaj).Value Then
                        formperm.Controls("framfouil" & ligmaj1).Visible = True
                    Else
                        formperm.Controls("framfouil" & ligmaj1).Visible = False
                    End If
                End If
            Next ligmaj1
    End Select
     
    'MISE EN FORME DICT
    Select Case Sheets("modele").Range("w" & ligmaj).Value
        Case "oui"
            formperm.visdict.Value = True
            formperm.typdict.Caption = "oui"
            formperm.Framdict.Visible = True
            If formperm.Optodict1.Value = True Then
                formperm.saisdict2.Visible = True
                formperm.Labdict2.Visible = True
            Else
                formperm.saisdict2.Visible = False
                formperm.Labdict2.Visible = False
            End If
     
        Case "non"
            formperm.visdict.Value = False
            formperm.typdict.Caption = "non"
            formperm.Framdict.Visible = False
    End Select
     
    'MISE EN FORME HORAIRES
    Select Case Sheets("modele").Range("y" & ligmaj).Value
        Case "non"
            formperm.vishorair.Value = False
            formperm.typhorair.Caption = "non"
            formperm.Framhorair.Visible = False
     
        Case "ouisfdim"
            formperm.vishorair.Value = True
            formperm.typhorair.Caption = "ouisfdim"
            formperm.Framhorair.Visible = True
            formperm.saishorair4.Visible = False
     
        Case "ouidim"
            formperm.vishorair.Value = True
            formperm.typhorair.Caption = "ouidim"
            formperm.Framhorair.Visible = True
            formperm.saishorair4.Visible = True
    End Select
     
    'MISE EN FORME COUPURE
    Select Case Sheets("modele").Range("x" & ligmaj).Value
        Case "non"
            formperm.viscoupur.Value = False
            formperm.typcoupur.Caption = "non"
            formperm.Framcoupur.Visible = False
     
        Case "oui2date"
            formperm.viscoupur.Value = True
            formperm.typcoupur.Caption = "oui2date"
            formperm.Framcoupur.Visible = True
            charglistmaform "energie", 1, numod
            If formperm.Optocoupur1.Value = True Then
                For a = 2 To 5
                    formperm.Controls("labcoupur" & a).Visible = True
                    formperm.Controls("saiscoupur" & a).Visible = True
                    If a = 3 Or a = 4 Then formperm.Controls("butcoupur" & a).Visible = True
                Next a
            Else
                For a = 2 To 5
                    formperm.Controls("labcoupur" & a).Visible = False
                    formperm.Controls("saiscoupur" & a).Visible = False
                    If a = 3 Or a = 4 Then formperm.Controls("butcoupur" & a).Visible = False
                Next a
            End If
     
        Case "oui1date"
            formperm.viscoupur.Value = True
            formperm.typcoupur.Caption = "oui1date"
            formperm.Framcoupur.Visible = True
            charglistmaform "energie", 1, numod
            If formperm.Optocoupur1.Value = True Then
                For a = 2 To 5
                    If a = 4 Then
                        formperm.labcoupur4.Visible = False
                        formperm.saiscoupur4.Visible = False
                        formperm.butcoupur4.Visible = False
                    Else
                        formperm.Controls("labcoupur" & a).Visible = True
                        formperm.Controls("saiscoupur" & a).Visible = True
                        If a = 3 Then formperm.Controls("butcoupur" & a).Visible = True
                    End If
                Next a
            Else
                For a = 2 To 5
                    formperm.Controls("labcoupur" & a).Visible = False
                    formperm.Controls("saiscoupur" & a).Visible = False
                    If a = 3 Or a = 4 Then formperm.Controls("butcoupur" & a).Visible = False
                Next a
            End If
     
    End Select
     
    'MISE EN FORME CA
        'aucunes modifications dans l'affichage
     
    ' MISE EN FORME PRESTATAIRE
        'aucunes modifications dans l'affichage
     
    ' MISE EN FORME DOSSIER CLIENT
        'aucunes modifications dans l'affichage
     
    ' MISE EN FORME COMMUNE
        'aucunes modifications dans l'affichage
     
    ' MISE EN FORME AGGLO
        'aucunes modifications dans l'affichage
     
    ' MISE EN FORME DDE
        'aucunes modifications dans l'affichage
     
     
    End Sub
     
    Sub charglistmaform(liste As String, numero As Single, numodel As String)
     
    'liste à mettre à disposition
    'numero correspond au numero de champ (1 à 5)
     
    Dim feuille As String
    Dim controle As String
     
     
    Select Case liste
        Case "encomb"
            feuille = "encomb"
            controle = "saisterb" & numero & "1"
        Case "revet"
            feuille = "revet"
            controle = "saisterb" & numero & "2"
        Case "circul"
            feuille = "circul"
            controle = "saiscirc6"
        Case "techniq"
            feuille = "techniq"
            controle = "saisterb" & numero & "6"
        Case "energie"
            feuille = "energie"
            controle = "saiscoupur2"
        Case "fencomb"
            feuille = "encomb"
            controle = "saisfouil" & numero & "1"
        Case "ftechniq"
            feuille = "techniq"
            controle = "saisfouil" & numero & "2"
    End Select
     
    formperm.Controls(controle).Clear
    formperm.Controls(controle).ColumnCount = 2
    formperm.Controls(controle).ColumnWidths = "0pt;100pt"
     
    If feuille = "energie" Then
        ligmaj3 = 3
    Else
        For B = 3 To 53
            If numodel = Sheets(feuille).Cells(3, B).Value Then
                ligmaj3 = B
                Exit For
            End If
        Next B
    End If
    ligmaj4 = 4
    Do While Sheets(feuille).Range("a" & ligmaj4).Value <> ""
        If Sheets(feuille).Cells(ligmaj4, ligmaj3).Value = "OUI" Then
                formperm.Controls(controle).AddItem Sheets(feuille).Range("a" & ligmaj4).Value
                formperm.Controls(controle).list(formperm.Controls(controle).ListCount - 1, 1) = Sheets(feuille).Range("b" & ligmaj4).Value
        End If
        ligmaj4 = ligmaj4 + 1
    Loop
     
    End Sub
    Sub majpageperm(VISU As String)
     
    'mettre visu à "envoie" ou "suivi"
    'envoie : permet d'envoyer la permission voirie (utiliser pour nouveau ou modif), affichage historique non disponible
    'suivi: permet de faire les relances ou inscrire le suivi, affichage historique disponible
     
    num = formperm.MultiPage1.Value
     
    Select Case VISU
        Case "envoie"
            formperm.boutenv.Visible = False
            formperm.boutenv.Caption = "ENVOYER"
            formperm.MultiPage1.Page10.Visible = False
            formperm.boutrel.Visible = False
            formperm.boutrec.Visible = False
        Case "suivi"
            formperm.boutenv.Visible = True
            formperm.boutenv.Caption = "MODIFIER"
            formperm.MultiPage1.Page10.Visible = True
            formperm.boutcenreg.Visible = False
            formperm.boutcmail.Visible = False
            formperm.boutmodel.Visible = False
    End Select
     
    If formperm.infdatrec.Value = "" Then
    Else
        formperm.boutrel.Visible = False
    End If
     
    formperm.MultiPage1.page2.Visible = False
    formperm.MultiPage1.page3.Visible = False
    formperm.MultiPage1.Page4.Visible = False
    formperm.MultiPage1.Page5.Visible = False
    formperm.MultiPage1.Page6.Visible = False
    formperm.MultiPage1.Page7.Visible = False
    formperm.MultiPage1.Page8.Visible = False
    formperm.MultiPage1.Page9.Visible = False
    formperm.MultiPage1.Page11.Visible = False
    formperm.MultiPage1.page12.Visible = False
    formperm.boutmodel.Visible = False
    formperm.saismodel.Visible = False
     
    If formperm.saisnumdoss.Value = "" Or formperm.saisnomcli.Value = "" Then
        formperm.MultiPage1.Visible = False
        formperm.boutmodel.Visible = False
        formperm.saismodel.Visible = False
        Exit Sub
    Else
        formperm.MultiPage1.Visible = True
        If formperm.visint.Value = False Then formperm.Frame26.Visible = False Else formperm.Frame26.Visible = True
        formperm.Framca.Visible = False
        formperm.Framprest.Visible = False
        formperm.boutmodel.Visible = False
        formperm.saismodel.Visible = False
    End If
     
    If formperm.saismair1b.Caption = "" Then
    Else
        If VISU = "envoie" Then formperm.boutmodel.Visible = True
        formperm.saismodel.Visible = True
        formperm.Framca.Visible = True
        formperm.Framprest.Visible = True
        If formperm.visint.Value = True Then formperm.Frame26.Visible = True
        If formperm.saisca1b.Caption = "" Or formperm.saismair1b.Caption = "" Or formperm.saisprest1b.Caption = "" Then
        Else
           ' If formperm.Frame26.Visible = False Then  GoTo suitmajpageperm1
            If formperm.Frame26.Visible = True And formperm.optyptr1.Value = False And formperm.optyptr2.Value = False And formperm.optyptr3.Value = False And formperm.optyptr4.Value = False Then
            Else
    'suitmajpageperm1:
                If formperm.saismodel.Caption = "MODELE CERFA A SELECTIONNER" Or formperm.saismodel.Caption = "" Then
                Else
                    If formperm.visadres.Value = True Then
                        formperm.MultiPage1.page2.Visible = True
                        If formperm.visprec.Value = True Then
                            formperm.MultiPage1.page3.Visible = True
                            test = False
                            If formperm.Framprec2.Visible = True Then
                                If formperm.saisprec5.Value = False And formperm.saisprec6.Value = False Then
                                    test = False
                                Else
                                    test = True
                                End If
                            Else
                                test = True
                            End If
                        Else
                            test = True
                        End If
                        If test = True Then
                            If formperm.saisadres11.Value = "" Or formperm.saisadres14.Value = "" Or formperm.saisadres15.Value = "" Or formperm.saisadres16.Value = "" Then
                                test = False
                            Else
                                test = True
                            End If
                        End If
                        If test = True Then
                            If formperm.saisadres12.Visible = True And formperm.saisadres12.Value = "" Then
                            Else
                                For a = 1 To 5
                                    If formperm.typadres.Caption = "simplnum" Or formperm.typadres.Caption = "multinum" Or formperm.typadres.Caption = "simplnumsanc" Or formperm.typadres.Caption = "multinumsanc" Then
                                        If formperm.Controls("saisadres" & a & "4").Value = "" Then
                                            nom = ""
                                        Else
                                            nom = formperm.Controls("saisadres" & a & "1").Value & " " & formperm.Controls("saisadres" & a & "3").Value & " " & _
                                            formperm.Controls("saisadres" & a & "4").Value & " " & formperm.Controls("saisadres" & a & "5").Value & " " & formperm.Controls("saisadres" & a & "6").Value
                                        End If
                                    Else
                                        If formperm.Controls("saisadres" & a & "1").Value = "" Or formperm.Controls("saisadres" & a & "2").Value = "" Then
                                            nom = ""
                                        Else
                                            nom = formperm.Controls("saisadres" & a & "1").Value & " à " & formperm.Controls("saisadres" & a & "2").Value & " " & _
                                            formperm.Controls("saisadres" & a & "4").Value & " " & formperm.Controls("saisadres" & a & "5").Value & " " & formperm.Controls("saisadres" & a & "6").Value
                                        End If
                                    End If
                                    formperm.Controls("Labterbad" & a).Caption = nom
                                    formperm.Controls("Labdatad" & a).Caption = nom
                                    formperm.Controls("Labterrad" & a).Caption = nom
                                Next a
                                If formperm.visurba.Value = True Then formperm.MultiPage1.Page4.Visible = True
                                If formperm.visterr.Value = True Then formperm.MultiPage1.Page5.Visible = True
                                If formperm.visterb.Value = True Then formperm.MultiPage1.Page8.Visible = True
                                If formperm.viscirc.Value = True Then formperm.MultiPage1.Page9.Visible = True
                                If formperm.visfouil.Value = True Then formperm.MultiPage1.Page11.Visible = True
                                If formperm.visterr.Value = False And formperm.visterb.Value = False Then
                                    Load formerreur
                                        formerreur.titre.Caption = "PROBLEME AVEC LE MODELE D ARRETE DE VOIRIE"
                                        formerreur.mess.Caption = "Veuillez contacter le concepteur et donner ce code erreur : majpageperm-2"
                                    formerreur.Show vbModal
                                    Unload formerreur
                                    End
                                End If
                                'test les obligatoires pages terrassement
                                test = True
    '                            If formperm.visterr.Value = True Then
     '                               test = False
     '                               For a = 1 To 6
     '                                   If formperm.Controls("saisterr1" & a).Visible = True Then
     '                                       If formperm.Controls("saisterr1" & a).Value <> "" Then
     '                                           test = True
     '                                       Else
     '                                           test = False
     '                                       End If
     '                                   Else
     '                                       test = True
     '                                   End If
     '                                   If test = False Then Exit For
     ''                               Next a
     '                           End If
                                'test les obligatoires pages terrassement 2
     '                           If formperm.visterb.Value = True Then
     '                               test = False
     '                               For a = 1 To 6
     '                                   If formperm.Controls("saisterb1" & a).Visible = True Then
     '                                       If formperm.Controls("saisterb1" & a).Value <> "" Then
     '                                           test = True
     '                                       Else
     '                                           test = False
     '                                       End If
     '                                   Else
     '                                       test = True
     '                                   End If
     '                                   If test = False Then Exit For
     '                               Next a
     '                           End If
     '                           'test les obligatoires pages fouille
     '                           If test = True Then
     '                               If formperm.visfouil.Value = True Then
     '                                   test = False
     '                                   For a = 1 To 5
     '                                       If formperm.Controls("saisfouil1" & a).Visible = True Then
     '                                           If a = 1 Or a = 2 Then
     '                                               If formperm.Controls("saisfouil1" & a).ListIndex = -1 Then Else test = True
     '                                           Else
     '                                               If formperm.Controls("saisfouil1" & a).Value = "" Then Else test = True
     '                                           End If
     '                                       End If
     '                                       If test = False Then Exit For
     '                                   Next a
     '                               End If
     '                           End If
                                'SUITE DE TEST POUR AFFICHAGE PAGE
                                If test = True Then
                                    If formperm.visdat.Value = True Then
                                        formperm.MultiPage1.Page6.Visible = True
                                        If formperm.vishorair = True Or formperm.viscoupur.Value = True Or formperm.visdict.Value = True Then formperm.MultiPage1.page12.Visible = True
     '                                   If formperm.saisdat11.Value = "" Then
     '                                   Else
    '                                        If formperm.typdat.Caption = "simples2" Or formperm.typdat.Caption = "multiles2" Then
    '                                            If formperm.saisdat11.Value = "" Or formperm.saisdat13.Value = "" Then
    '                                            Else
    '                                                formperm.saisdat12.Value = DateDiff("d", formperm.saisdat11.Value, formperm.saisdat13.Value)
    '                                            End If
    '                                            For a = 2 To 5
    '                                                If formperm.Controls("Framdat" & a).Visible = True Then
    '                                                    If formperm.Controls("saisdat" & a & "1").Value = "" Or formperm.Controls("saisdat" & a & "3").Value = "" Then
    '                                                    Else
    '                                                        formperm.Controls("saisdat" & a & "2").Value = DateDiff("d", formperm.Controls("saisdat" & a & "1").Value, formperm.Controls("saisdat" & a & "3").Value)
    '                                                    End If
    '                                                End If
    '                                            Next a
    '                                        End If
                                            test = True
     '                                       If (formperm.saisdat12.Visible = True And formperm.saisdat12.Value <> "") Or (formperm.saisdat13.Visible = True And formperm.saisdat13.Value <> "") Then test = True
     '                                       If test = True Then
     '                                           If formperm.visdict.Value = True Then
     '                                               If formperm.Optndict1.Value = False And formperm.Optodict1.Value = False Then test = False
     '                                           End If
     '                                       End If
     '                                       If test = True Then
     '                                           If formperm.viscoupur.Value = True Then
     '                                               If formperm.Optncoupur1.Value = False And formperm.Optocoupur1.Value = False Then test = False
     '                                           End If
     '                                       End If
                                            If test = True Then formperm.MultiPage1.Page7.Visible = True
     '                                   End If
                                    Else
                                        Load formerreur
                                            formerreur.titre.Caption = "PROBLEME AVEC LE MODELE D ARRETE DE VOIRIE"
                                            formerreur.mess.Caption = "Veuillez contacter le concepteur et donner ce code erreur : majpageperm-3"
                                        formerreur.Show vbModal
                                        Unload formerreur
                                        Unload formperm
                                        Exit Sub
                                    End If
                                End If
                            End If
                        End If
                    Else
                        Load formerreur
                            formerreur.titre.Caption = "PROBLEME AVEC LE MODELE D ARRETE DE VOIRIE"
                            formerreur.mess.Caption = "Veuillez contacter le concepteur et donner ce code erreur : majpageperm-1"
                        formerreur.Show vbModal
                        Unload formerreur
                        Unload formperm
                        End
                    End If
                End If
            End If
        End If
    End If
    formperm.MultiPage1.Value = num
     
    End Sub
    Du coup une question que je ne comprends pas :

    Pourquoi le STOP règle t'il le problème ?

    Au plaisir de vous lire

  4. #4
    Membre régulier
    Homme Profil pro
    Chargé d'affaire
    Inscrit en
    Février 2008
    Messages
    143
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Pyrénées Orientales (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Chargé d'affaire
    Secteur : Service public

    Informations forums :
    Inscription : Février 2008
    Messages : 143
    Points : 106
    Points
    106
    Par défaut
    pour aider à la compréhension de mon problème à la bonne âme voulant m'aider !!!

    En fait il plante lorsque je remplit un label ou un textbox quelqu'il soit.
    Il n'y a pas de codes dans le label ou le textbox qui pourraient lancer une autre sub à l'intérieur et effectuer ainsi une boucle permanente.

    J'ai essayé de supprimer la ligne du dessous en la passant en commentaires et j'ai fait cela pour toutes les lignes qui suivaient lorsqu'elle saisissait dans le form !!!

    Qu'est ce qui peut faire planter excel quand essaye d'écrire dans un form ?

    merci pour votre aide

  5. #5
    Membre régulier
    Homme Profil pro
    Chargé d'affaire
    Inscrit en
    Février 2008
    Messages
    143
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Pyrénées Orientales (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Chargé d'affaire
    Secteur : Service public

    Informations forums :
    Inscription : Février 2008
    Messages : 143
    Points : 106
    Points
    106
    Par défaut PROBLEME TROUVEE MAIS BESOIN CONSEIL POUR LA SOLUTION


    Bonjour, après de longues heures, la nuit m'a apporté le problème.

    Tous mes champs LABEL et TEXTBOX sont situé dans un MULTIPAGE dont je modifie très souvent la mise page de son contenu.

    Le problème vient de là, le MULTIPAGE ne supporte pas tous ces changements et devient instable qui provoque ces fermetures d'EXCEL non désirées.

    Du coup 2 solutions :

    -- Je supprime LE MULTIPAGE pour une autre solution à plusieurs FORM, celle là je maîtrise.

    -- J'apporte quelques correctifs pour stabiliser le MULTIPAGE et là je viens vers vous pour les solutions si vous en avez ???

    Je n'ai pas le temps de commencer aujourd'hui et donc je compte sur vos avis avant de me lancer.

    Au plaisir de vous lire.

    Merci

  6. #6
    Membre régulier
    Homme Profil pro
    Chargé d'affaire
    Inscrit en
    Février 2008
    Messages
    143
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Pyrénées Orientales (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Chargé d'affaire
    Secteur : Service public

    Informations forums :
    Inscription : Février 2008
    Messages : 143
    Points : 106
    Points
    106
    Par défaut cloture
    bonjour,

    Sans réponse, c'est qu'il y a guère d'autres solutions, donc je clos le sujet
    merci

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [XL-2007] VBA ferme Excel lors de son exécution
    Par Albatros182 dans le forum Excel
    Réponses: 0
    Dernier message: 23/03/2020, 21h15
  2. Réponses: 0
    Dernier message: 01/06/2016, 10h54
  3. Erreur lors de l'Exécution d'une appli traitant un classeur Excel.
    Par Luigi13 dans le forum VB 6 et antérieur
    Réponses: 10
    Dernier message: 30/03/2010, 14h31
  4. Plantage général d'excel lors de l'exécution d'une macro
    Par Esmax666 dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 19/10/2009, 10h31
  5. Réponses: 11
    Dernier message: 07/07/2006, 19h24

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo