Réactiver le copier/coller

Bonjour à tous,

J'utilise le code ci-dessous pour désactiver le copier/coller, mais j'aimerais que par un autre code pouvoir réactiver?

Merci d'avance pour votre aide.

Bonne journée,

Setila

'*** In the ThisWorkbook Module ***
Option Explicit

Private Sub Workbook_Activate()
    Call ToggleCutCopyAndPaste(False)
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Call ToggleCutCopyAndPaste(True)
End Sub

Private Sub Workbook_Deactivate()
    Call ToggleCutCopyAndPaste(True)
End Sub

Private Sub Workbook_Open()
    Call ToggleCutCopyAndPaste(False)
End Sub

 '*** In a standard module ***
Option Explicit

Sub ToggleCutCopyAndPaste(Allow As Boolean)
     'Activate/deactivate cut, copy, paste and pastespecial menu items
    Call EnableMenuItem(21, Allow) ' cut
    Call EnableMenuItem(19, Allow) ' copy
    Call EnableMenuItem(22, Allow) ' paste
    Call EnableMenuItem(755, Allow) ' pastespecial

     'Activate/deactivate drag and drop ability
    Application.CellDragAndDrop = Allow

     'Activate/deactivate cut, copy, paste and pastespecial shortcut keys
    With Application
        Select Case Allow
        Case Is = False
            .OnKey "^c", "CutCopyPasteDisabled"
            .OnKey "^v", "CutCopyPasteDisabled"
            .OnKey "^x", "CutCopyPasteDisabled"
            .OnKey "+{DEL}", "CutCopyPasteDisabled"
            .OnKey "^{INSERT}", "CutCopyPasteDisabled"
        Case Is = True
            .OnKey "^c"
            .OnKey "^v"
            .OnKey "^x"
            .OnKey "+{DEL}"
            .OnKey "^{INSERT}"
        End Select
    End With
End Sub

Sub EnableMenuItem(ctlId As Integer, Enabled As Boolean)
     'Activate/Deactivate specific menu item
    Dim cBar As CommandBar
    Dim cBarCtrl As CommandBarControl
    For Each cBar In Application.CommandBars
        If cBar.Name <> "Clipboard" Then
            Set cBarCtrl = cBar.FindControl(ID:=ctlId, recursive:=True)
            If Not cBarCtrl Is Nothing Then cBarCtrl.Enabled = Enabled
        End If
    Next
End Sub

Sub CutCopyPasteDisabled()
     'Inform user that the functions have been disabled
    MsgBox "Sorry! Afin d'éviter les Bugs!!! les Cutting, copying and pasting sont désactivés dans ce classeur!"
End Sub

bonjour

mon avis : tu te lances dans une usine à gaz

interdire, puis autoriser et etc.

trop compliqué

mets des protections sur ton fichier (cellules contenant des formules)

et ça suffira

amitiés

Hello jmd,

En effet, j'interdit le copier/coller à mes employés car bug à répétition! et depuis plusieurs semaines ça marche très bien!

Mais je veux l'autoriser que pour moi?

Avec un code ou un raccourci peut importe?

Merci

Setila

re

laisse la macro "interdit de coller"

à te relire

Re,

Ca ne fonctionne pas? voici le fichier et le mot de passe est "1234"

J'ai bien pressé la touch MAJ à l'ouverture du classeur!?

11semaine-51bis.xlsm (619.24 Ko)

Merci

Setila

Hello tout le monde,

J'ai trouvé la solution, j'ajoute un module avec :

Sub Copy()
     Call ToggleCutCopyAndPaste(True)
End Sub

et un racourci ctrl+A

Qu'en pensez-vous?

Merci

Setila

Rechercher des sujets similaires à "reactiver copier coller"