Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

Amélioration d'un fichier de conf.

babap1

XLDnaute Occasionnel
Bon jour le forum,

j'aimerai améliorer mon fichier excel et j'ai besoin de queqlues conseils sur les points suivants :

1/ mes feuilles sont protégées par un mdp qui est transparent dans mon code VBA... et ce n'est pas terrible ! Y a-t-il un autre moyen de protection ?
2/ à l'ouverture de ma feuille, comment masquer tous les menus pour que l'utilisateur lambda ne puisse rien modifier ? et comment n'afficher que les colonnes A->AD ?
3/ comment créer son propre menu dans une toolbar customisée ? au lieu d'avoir des boutons (add, modify, del..) ?
4/ comment rendre inactif la suppression des 4 premières lignes avec ma fonction delete()?
5/ ma fonction copy/paste fonctionne pour une ligne mais j'aimerai pouvoir copier/coller plusieurs lignes sélectionnées...
6/ * si ma toutes mes cellules O5->Ox sont vides alors masquer les colonnes P->V
* si ma toutes mes cellules W5->Wx sont vides alors masquer les colonnes X->AD

7/ j'ai l'impression que mon code peut encore être allégé mais j'aimerai ne pas faire de bêtises...
par exemple :

Code:
Sub Process_CheckBox(pObject)
    Sheet1.Unprotect ("snec")
    Dim CurrentEquipmentRow As Integer
    Dim i As Integer
    
    'Select the row with the equipment you want to modify
    CurrentEquipmentRow = Selection.Row
    
    'If the FTP CheckBox is true, allow the textboxes relative to the FTP connexion
    If Cbx_FTP.Value = True Then
        Txt_FTPPort.Enabled = True
        Txt_FTPPort.BackColor = &H80000005
        Txt_FTPLogin.Enabled = True
        Txt_FTPLogin.BackColor = &H80000005
        Txt_FTPPassword.Enabled = True
        Txt_FTPPassword.BackColor = &H80000005
    'If the FTP CheckBox is false, hide textboxes relative to the FTP connexion
    Else
        Txt_FTPPort.Enabled = False
        Txt_FTPPort.BackColor = &H8000000B
        Txt_FTPLogin.Enabled = False
        Txt_FTPLogin.BackColor = &H8000000B
        Txt_FTPPassword.Enabled = False
        Txt_FTPPassword.BackColor = &H8000000B
        
        'Clear the FTP cells
        Range("A" & CurrentEquipmentRow).Select
        With ActiveCell
            For i = 2 To 5
                .Offset(0, i).Value = ""
            Next i
        End With
    End If
    
     'If the Hop 1 CheckBox is true, allow the textboxes relative to this Hop connexion
    If Cbx_Hop1.Value = True Then
        Cbx_Hop2.Enabled = True
        B_AddHop1.Enabled = True
        B_ModifyHop1.Enabled = True
        Opt_IpAddress1.Enabled = True
        Opt_IpAddress1.BackColor = &HE0E0E0
        Opt_Name1.Enabled = True
        Opt_Name1.BackColor = &HE0E0E0
        Txt_EqIp1.Enabled = True
        Txt_EqIp1.BackColor = &H80000005
        Cbx_CxType1.Enabled = True
        Cbx_CxType1.BackColor = &H80000005
        Txt_EqPort1.Enabled = True
        Txt_EqPort1.BackColor = &H80000005
        Txt_EqLogin1.Enabled = True
        Txt_EqLogin1.BackColor = &H80000005
        Txt_EqPassword1.Enabled = True
        Txt_EqPassword1.BackColor = &H80000005
        Txt_EqLoginPrompt1.Enabled = True
        Txt_EqLoginPrompt1.BackColor = &H80000005
        Txt_EqPassPrompt1.Enabled = True
        Txt_EqPassPrompt1.BackColor = &H80000005
        Txt_EqPrompt1.Enabled = True
        Txt_EqPrompt1.BackColor = &H80000005
    'If the Hop 1 CheckBox is false, hide textboxes relative to this Hop connexion
    Else
        If Cbx_Hop1.Value = False Then
            Cbx_Hop2.Enabled = False
            B_AddHop1.Enabled = False
            B_ModifyHop1.Enabled = False
            Opt_IpAddress1.Enabled = False
            Opt_IpAddress1.BackColor = &HE0E0E0
            Opt_Name1.Enabled = False
            Opt_Name1.BackColor = &HE0E0E0
            Txt_EqIp1.Enabled = False
            Txt_EqIp1.BackColor = &H8000000B
            Cbx_CxType1.Enabled = False
            Cbx_CxType1.BackColor = &H8000000B
            Txt_EqPort1.Enabled = False
            Txt_EqPort1.BackColor = &H8000000B
            Txt_EqLogin1.Enabled = False
            Txt_EqLogin1.BackColor = &H8000000B
            Txt_EqPassword1.Enabled = False
            Txt_EqPassword1.BackColor = &H8000000B
            Txt_EqLoginPrompt1.Enabled = False
            Txt_EqLoginPrompt1.BackColor = &H8000000B
            Txt_EqPassPrompt1.Enabled = False
            Txt_EqPassPrompt1.BackColor = &H8000000B
            Txt_EqPrompt1.Enabled = False
            Txt_EqPrompt1.BackColor = &H8000000B
            
            'Clear the first hop cells
            Range("O" & CurrentEquipmentRow).Select
            With ActiveCell
                For i = 0 To 15
                    .Offset(0, i).Value = ""
                Next i
            End With
        End If
    End If
    
     'If the Hop 2 CheckBox is true, allow the textboxes relative to this Hop connexion
    If Cbx_Hop2.Enabled = True Then
        If Cbx_Hop2.Value = True Then
            B_AddHop2.Enabled = True
            B_ModifyHop2.Enabled = True
            Opt_IpAddress2.Enabled = True
            Opt_IpAddress2.BackColor = &HE0E0E0
            Opt_Name2.Enabled = True
            Opt_Name2.BackColor = &HE0E0E0
            Txt_EqIp2.Enabled = True
            Txt_EqIp2.BackColor = &H80000005
            Cbx_CxType2.Enabled = True
            Cbx_CxType2.BackColor = &H80000005
            Txt_EqPort2.Enabled = True
            Txt_EqPort2.BackColor = &H80000005
            Txt_EqLogin2.Enabled = True
            Txt_EqLogin2.BackColor = &H80000005
            Txt_EqPassword2.Enabled = True
            Txt_EqPassword2.BackColor = &H80000005
            Txt_EqLoginPrompt2.Enabled = True
            Txt_EqLoginPrompt2.BackColor = &H80000005
            Txt_EqPassPrompt2.Enabled = True
            Txt_EqPassPrompt2.BackColor = &H80000005
            Txt_EqPrompt2.Enabled = True
            Txt_EqPrompt2.BackColor = &H80000005
       End If
        
    'If the Hop 2 CheckBox is false, hide textboxes relative to this Hop connexion
    Else
            B_AddHop2.Enabled = False
            B_ModifyHop2.Enabled = False
            Opt_IpAddress2.Enabled = False
            Opt_IpAddress2.BackColor = &HE0E0E0
            Opt_Name2.Enabled = False
            Opt_Name2.BackColor = &HE0E0E0
            Txt_EqIp2.Enabled = False
            Txt_EqIp2.BackColor = &H8000000B
            Cbx_CxType2.Enabled = False
            Cbx_CxType2.BackColor = &H8000000B
            Txt_EqPort2.Enabled = False
            Txt_EqPort2.BackColor = &H8000000B
            Txt_EqLogin2.Enabled = False
            Txt_EqLogin2.BackColor = &H8000000B
            Txt_EqPassword2.Enabled = False
            Txt_EqPassword2.BackColor = &H8000000B
            Txt_EqLoginPrompt2.Enabled = False
            Txt_EqLoginPrompt2.BackColor = &H8000000B
            Txt_EqPassPrompt2.Enabled = False
            Txt_EqPassPrompt2.BackColor = &H8000000B
            Txt_EqPrompt2.Enabled = False
            Txt_EqPrompt2.BackColor = &H8000000B
            
            'Select the last line
            Range("W" & CurrentEquipmentRow).Select
            With ActiveCell
                For i = 0 To 7
                    .Offset(0, i).Value = ""
                Next i
            End With
        End If
    Sheet1.Protect ("snec")
End Sub

Private Sub Cbx_FTP_Click()
    Process_CheckBox Cbx_FTP
End Sub

Private Sub Cbx_Hop1_Click()
    Process_CheckBox Cbx_Hop1
End Sub

Private Sub Cbx_Hop2_Click()
    Process_CheckBox Cbx_Hop2
End Sub

Cette fonction est surement simplifiable mais je ne sais pas par quel bout commencer !

voila en PJ mon petit programme. Est-il possible d'avoir un coup de main pour répondre à mes questions?

D'avance merci , Baptiste
 

Pièces jointes

  • conf.zip
    41.6 KB · Affichages: 27

Discussions similaires

Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…