Note: The other languages of the website are Google-translated. Back to English
Se connecter  \/ 
x
or
x
S’enregistrer  \/ 
x

or

Comment désactiver les fonctions couper, copier et coller dans Excel?

Supposons que vous ayez un classeur contenant des données importantes que vous devez protéger contre le coupage, la copie et le collage. Comment y parvenir? Cet article fournit une méthode VBA pour vous permettre de désactiver les fonctions couper, copier et coller en même temps dans un classeur Excel.

Désactivez les fonctions couper, copier et coller avec le code VBA


Désactivez les fonctions couper, copier et coller avec le code VBA

Veuillez procéder comme suit pour désactiver les fonctions couper, copier et coller dans un classeur Excel.

1. Dans le classeur, vous devez désactiver les fonctions couper, copier et coller, appuyez sur le bouton autre + F11 touches simultanément pour ouvrir le Microsoft Visual Basic pour applications fenêtre.

2. dans le Microsoft Visual Basic pour applications fenêtre, veuillez double-cliquer Ce classeur à gauche Projet volet, puis copiez et collez le code VBA ci-dessous dans le Ce classeur (code) la fenêtre. Voir la capture d'écran:

Code VBA: désactivez les fonctions couper, copier et coller en même temps dans Excel

Private Sub Workbook_Activate()
Application.CutCopyMode = False
Application.OnKey "^c", ""
Application.CellDragAndDrop = False
End Sub

Private Sub Workbook_Deactivate()
Application.CellDragAndDrop = True
Application.OnKey "^c"
Application.CutCopyMode = False
End Sub

Private Sub Workbook_WindowActivate(ByVal Wn As Window)
Application.CutCopyMode = False
Application.OnKey "^c", ""
Application.CellDragAndDrop = False
End Sub

Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
Application.CellDragAndDrop = True
Application.OnKey "^c"
Application.CutCopyMode = False
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Application.CutCopyMode = False
End Sub

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Application.OnKey "^c", ""
Application.CellDragAndDrop = False
Application.CutCopyMode = False
End Sub

Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
Application.CutCopyMode = False
End Sub

3. Ensuite, appuyez sur le autre + Q touches pour quitter Microsoft Visual Basic pour applications fenêtre.

Désormais, vous ne pouvez pas couper ou copier les données de ce classeur, en attendant, les données que vous avez copiées à partir d'autres feuilles ou classeurs ne peuvent pas être collées dans ce classeur.

importante: La fonction glisser-déposer est également désactivée après l'exécution du code VBA ci-dessus.


Articles connexes:


Les meilleurs outils de productivité de bureau

Kutools for Excel résout la plupart de vos problèmes et augmente votre productivité de 80%

  • Réutilisation: Insérer rapidement formules complexes, graphiques et tout ce que vous avez utilisé auparavant; Crypter les cellules avec mot de passe; Créer une liste de diffusion et envoyer des e-mails ...
  • Barre Super Formula (modifiez facilement plusieurs lignes de texte et de formule); Disposition de lecture (lire et modifier facilement un grand nombre de cellules); Coller dans la plage filtrée...
  • Fusionner les cellules / lignes / colonnes sans perdre de données; Contenu des cellules divisées; Combiner des lignes / colonnes en double... Empêcher les cellules en double; Comparer les gammes...
  • Sélectionnez Dupliquer ou Unique Lignes; Sélectionnez les lignes vides (toutes les cellules sont vides); Super Find et Fuzzy Find dans de nombreux classeurs; Sélection aléatoire ...
  • Copie exacte Plusieurs cellules sans changer la référence de formule; Créer automatiquement des références à plusieurs feuilles; Insérer des puces, Cases à cocher et plus encore ...
  • Extrait du texte, Ajouter du texte, Supprimer par position, Supprimer l'espace; Créer et imprimer des sous-totaux de pagination; Conversion entre le contenu et les commentaires des cellules...
  • Super filtre (enregistrer et appliquer des schémas de filtrage à d'autres feuilles); Tri avancé par mois / semaine / jour, fréquence et plus; Filtre spécial par gras, italique ...
  • Combiner des classeurs et des feuilles de travail; Fusionner les tableaux en fonction des colonnes clés; Diviser les données en plusieurs feuilles; Conversion par lots xls, xlsx et PDF...
  • Plus de 300 fonctionnalités puissantes. Prend en charge Office / Excel 2007-2019 et 365. Prend en charge toutes les langues. Déploiement facile dans votre entreprise ou organisation. Essai gratuit de 30 jours. Garantie de remboursement de 60 jours.
kte tab 201905

Office Tab apporte une interface à onglets à Office et simplifie considérablement votre travail

  • Activer l'édition et la lecture par onglets dans Word, Excel, PowerPoint, Publisher, Access, Visio et Project.
  • Ouvrez et créez plusieurs documents dans de nouveaux onglets de la même fenêtre, plutôt que dans de nouvelles fenêtres.
  • Augmente votre productivité de 50% et réduit des centaines de clics de souris chaque jour!
bas de cabine
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    la.king727@gmail.com · 8 months ago
    Reposting so it is public-apologizing in advance to administrators.

    This works great, how would one modify this to allow copy/paste in specific columns that have pull down menus tied to named ranges of acceptable input and only the acceptable input. For instance a name that is Jetson, George, 25, would allow a copy/paste of Jetson, George, 25 but would not allow Jeston, George, 26. Or a drag and fill that would result in Jetson, George, 25 then 26, then 27, etc.

    In my worksheet I want to completely disable cut/copy/paste in certain columns, then only allow copy/paste of acceptable data from drop downs.

    Thank you.
  • To post as a guest, your comment is unpublished.
    L King · 8 months ago
    This works great, how would one modify this to allow copy/paste in specific columns that have pull down menus tied to named ranges of acceptable input and only the acceptable input. For instance a name that is Jetson, George, 25, would allow a copy/paste of Jetson, George, 25 but would not allow Jeston, George, 26. Or a drag and fill that would result in Jetson, George, 25 then 26, then 27, etc.

    In my worksheet I want to completely disable cut/copy/paste in certain columns, then only allow cut copy paste of acceptable data from drop downs.

    Thank you.
  • To post as a guest, your comment is unpublished.
    Mohamed saber · 9 months ago
    use this code to disable copy cut & paste

    Private Sub Workbook_Activate()
    Application.CutCopyMode = False
    Application.OnKey "^c", ""
    Application.CellDragAndDrop = False
    End Sub

    Private Sub Workbook_Deactivate()
    Application.CellDragAndDrop = True
    Application.OnKey "^c"
    Application.CutCopyMode = False
    End Sub

    Private Sub Workbook_WindowActivate(ByVal Wn As Window)
    Application.CutCopyMode = False
    Application.OnKey "^c", ""
    Application.CellDragAndDrop = False
    End Sub

    Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
    Application.CellDragAndDrop = True
    Application.OnKey "^c"
    Application.CutCopyMode = False
    End Sub

    Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    Application.CutCopyMode = False
    End Sub

    Private Sub Workbook_SheetActivate(ByVal Sh As Object)
    Application.OnKey "^c", ""
    Application.CellDragAndDrop = False
    Application.CutCopyMode = False
    End Sub

    Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
    Application.CutCopyMode = False
    End Sub


    and want to enable these function again
  • To post as a guest, your comment is unpublished.
    Mohamed saber · 9 months ago
    I used this code & want to Re-enable again? how to re-enable it?
  • To post as a guest, your comment is unpublished.
    crystal · 1 years ago
    @tabbymulla Hi,
    If prevent pasting from any source, we need to prevent the Notepad feature, which may bring inconvenience. We do not recommend this. Sorry can't help you for that.
  • To post as a guest, your comment is unpublished.
    tabbymulla · 1 years ago
    This still allows pasting from Notepad or Microsoft Edge. Please see if there is a way prevent pasting from any source.
  • To post as a guest, your comment is unpublished.
    AMB · 1 years ago
    That code isn't working in my excel 2016 for a single sheet instead of the whole workbook
  • To post as a guest, your comment is unpublished.
    Harish · 1 years ago
    cut copy paste applicable Entire workbook. If i need this Code only i particular sheet.Is it Possible ??
    please help. we need only one sheet disable functions. another sheet we are working all functions...
  • To post as a guest, your comment is unpublished.
    Apolo · 1 years ago
    Thank you, very useful.
  • To post as a guest, your comment is unpublished.
    RAHUL MODI · 1 years ago
    THANKS SIR
  • To post as a guest, your comment is unpublished.
    Stuart Davis · 1 years ago
    @rafhtaher Hi, I used this to hide "Cut" from users and it works great unless you have a Table, the "Cut" miraculously re-appears when you select a cell in the Table, exactly what i'm trying to avoid. any ideas? thanks!
  • To post as a guest, your comment is unpublished.
    crystal · 2 years ago
    @rasheednoorpk@gmail.com Good day,
    Sorry can't help you with that. Welcome to post any question in our forum: https://www.extendoffice.com/forum.html. Thank you for your comment.
  • To post as a guest, your comment is unpublished.
    rasheednoorpk@gmail.com · 2 years ago
    Thanks it works perfect ....can it be applied on a range only somehow?
  • To post as a guest, your comment is unpublished.
    Sam · 2 years ago
    It really works well, thanks a lot.
  • To post as a guest, your comment is unpublished.
    Vic · 2 years ago
    Hi, the code works well thanks.
    However, the read only option was enabled. (if you don't want to modify). If I set ..File, save as, tools, general options, read only recommended.. then the code does not work.

    Thanks in advance.
  • To post as a guest, your comment is unpublished.
    Al Hammad · 2 years ago
    Thank your for your direction.I am Trying in office 2013 ,but nothing changed.
  • To post as a guest, your comment is unpublished.
    crystal · 2 years ago
    @mags Good Day,
    The VBA1in above comment is the replacement of the original code.
  • To post as a guest, your comment is unpublished.
    garak0410 · 2 years ago
    @crystal One last question - Where does this code go and how does it get executed? The project this needs to work with attaches an XLA file to the Excel sheet that contains much of the code. Didn't know if this needs to go into a module or the code behind this sheet. Thanks...
  • To post as a guest, your comment is unpublished.
    crystal · 2 years ago
    @garak0410 Good day,
    The following VBA code can help you to solve the problem. And don't forget to replace "Sheet2" in the code with your sheet name.

    Public mJWSName As String

    Private Sub Workbook_Open()
    mJWSName = "Sheet2"
    End Sub

    Private Sub Workbook_Activate()
    If ActiveSheet.Name = mJWSName Then
    Application.CutCopyMode = False
    Application.OnKey "^c", ""
    Application.CellDragAndDrop = False
    End If
    End Sub

    Private Sub Workbook_Deactivate()
    Application.OnKey "^c", ""
    Application.CellDragAndDrop = True
    Application.CutCopyMode = False
    End Sub


    Private Sub Workbook_WindowActivate(ByVal Wn As Window)
    If ActiveSheet.Name = mJWSName Then
    Application.CutCopyMode = False
    Application.OnKey "^c", ""
    Application.CellDragAndDrop = False
    End If
    End Sub

    Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
    Application.OnKey "^c"
    Application.CellDragAndDrop = True
    Application.CutCopyMode = False
    End Sub

    Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    On Error Resume Next
    If Sh.Name = mJWSName Then
    Application.CutCopyMode = False
    End If
    End Sub

    Private Sub Workbook_SheetActivate(ByVal Sh As Object)
    On Error Resume Next
    If Sh.Name = mJWSName Then
    Application.OnKey "^c", ""
    Application.CellDragAndDrop = False
    Application.CutCopyMode = False
    End If
    End Sub

    Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
    Application.OnKey "^c"
    Application.CellDragAndDrop = True
    Application.CutCopyMode = False
    End Sub
  • To post as a guest, your comment is unpublished.
    crystal · 2 years ago
    @ERCA Good day,
    The code works well in my case. May I know your Office version?
  • To post as a guest, your comment is unpublished.
    ERCA · 2 years ago
    @crystal I tried just like you said but nothing happends. A want exactly the same, Only the
    "Cut" function disabled. I need to disable the "cut" option from Rightclick buton option and from the toolbar.
    It is posible crystal??
  • To post as a guest, your comment is unpublished.
    garak0410 · 2 years ago
    Was super glad to find this post but I need a little help in limiting this to a single worksheet in a multi-worksheet Workbook. And need to know how to execute this without user intervention...we need this ASAP on a workbook to help prevent errors.
  • To post as a guest, your comment is unpublished.
    crystal · 2 years ago
    @Carmelo Hi Carmelo,
    Please copy and paste the below code into the Workbook code window in your workbook and then save it as an Excel Macro-enabled workbook. Then the "Cut" function will be disabled.

    Option Explicit
    Private WithEvents Cmbrs As CommandBars

    Private Sub Workbook_Open()
    Set Cmbrs = Application.CommandBars
    End Sub

    Private Sub Workbook_Activate()
    If Application.CutCopyMode = 2 Then
    Application.CutCopyMode = 0
    End If
    End Sub

    Private Sub Cmbrs_OnUpdate()
    If Me Is ActiveWorkbook Then
    If Application.CutCopyMode = 2 Then
    Application.CutCopyMode = 0
    MsgBox "Cut Operations disabled"
    End If
    End If
    End Sub
  • To post as a guest, your comment is unpublished.
    crystal · 2 years ago
    @Linda Hello Linda,
    You can solve the problem without using VBA code.
    Right click the cell and select Format Cells from the context menu, uncheck the Locked box under the Protection tab in the dialog. And then protect the worksheet with password.
  • To post as a guest, your comment is unpublished.
    mags · 2 years ago
    @crystal This doesn't seem to have worked for me - should I delete the original VBA code and then paste the above in to enable the Cut, copy and paste function again?
  • To post as a guest, your comment is unpublished.
    Linda · 2 years ago
    Hi

    I´m a beginner of VBA codes and this code solved 99% of my problems.

    Is it possible to lock the hole sheet (as this code dose) but still have one cell unlocked?
    (Clarify, I would like to allow copy past in info in only one cell in the hole sheet).

    Best regards
    L
  • To post as a guest, your comment is unpublished.
    Carmelo · 3 years ago
    Hi,
    Is it possible to disable "CUT" only? but I could still use the Copy and Paste?
  • To post as a guest, your comment is unpublished.
    crystal · 3 years ago
    @midas.solarenergy@gmail.com Good Day,
    Thank you for your comment. I am trying to figure out the solution for Excel 2007. Please wait patiently.
  • To post as a guest, your comment is unpublished.
    midas.solarenergy@gmail.com · 3 years ago
    Dear,

    i want to disable cut, copy, paste in excel 2007 sheet
    can you share code for this
  • To post as a guest, your comment is unpublished.
    sa · 3 years ago
    @Martin have you found an answer?
  • To post as a guest, your comment is unpublished.
    crystal · 3 years ago
    @Sky Dear Sky
    Please run the below VBA1 (place the code in the ThisWorkbook module) to disable the cut, copy and paste function in your workbook.

    VBA1:
    Sub DelCopy()
    With Application
    .OnKey "^x", ""
    .OnKey "^c", ""
    .CommandBars("Cell").Controls(1).Enabled = False
    .CommandBars("Cell").Controls(2).Enabled = False
    End With
    End Sub

    And the run the VBA2 to enable all these functions back to your workbook.

    VBA2:
    Sub RecoverCopy()
    With Application
    .OnKey "^x"
    .OnKey "^c"
    .CommandBars("Cell").Controls(1).Enabled = True
    .CommandBars("Cell").Controls(2).Enabled = True
    End With
    End Sub
  • To post as a guest, your comment is unpublished.
    Sky · 3 years ago
    How to enable the cut, copy and paste function back? Please advice!
  • To post as a guest, your comment is unpublished.
    martinkunder1988@gmail.com · 3 years ago
    Thanks a Lot.Its working in entire worbook. Can we do the coding only for 1 sheet.Please help .
  • To post as a guest, your comment is unpublished.
    Martin · 3 years ago
    Thanks u Sir its working .But in Entire workbook. If i need this Code only i particular sheet.Is it Possible ??
  • To post as a guest, your comment is unpublished.
    rafhtaher · 3 years ago
    i do as above but the function of cut copy and past disabled in any excel file i open .why?