Note: The other languages of the website are Google-translated. Back to English
Zaloguj Się  \/ 
x
or
x
Rejestruję się  \/ 
x

or

Jak wyłączyć funkcje wycinania, kopiowania i wklejania w programie Excel?

Przypuśćmy, że masz skoroszyt z ważnymi danymi, które musisz chronić przed wycinaniem, kopiowaniem i wklejaniem. Jak to osiągnąć? W tym artykule przedstawiono metodę VBA, która umożliwia jednoczesne wyłączenie funkcji wycinania, kopiowania i wklejania w skoroszycie programu Excel.

Wyłącz funkcje wycinania, kopiowania i wklejania za pomocą kodu VBA


Wyłącz funkcje wycinania, kopiowania i wklejania za pomocą kodu VBA

Wykonaj następujące czynności, aby wyłączyć funkcje wycinania, kopiowania i wklejania w skoroszycie programu Excel.

1. W skoroszycie musisz wyłączyć funkcje wycinania, kopiowania i wklejania, naciśnij przycisk inny + F11 klawisze jednocześnie, aby otworzyć Microsoft Visual Basic for Applications okno.

2. w Microsoft Visual Basic for Applications kliknij dwukrotnie Ten zeszyt po lewej Projekt okienko, a następnie skopiuj i wklej poniższy kod VBA do pliku ThisWorkbook (kod) okno. Zobacz zrzut ekranu:

Kod VBA: wyłącz jednocześnie funkcje wycinania, kopiowania i wklejania w programie 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. Następnie naciśnij inny + Q klawisze, aby wyjść z Microsoft Visual Basic for Applications okno.

Teraz nie możesz wycinać ani kopiować danych z tego skoroszytu, tymczasem danych skopiowanych z innych arkuszy lub skoroszytów nie można wkleić do tego skoroszytu.

Uwagi: Funkcja przeciągnij i upuść jest również wyłączona po uruchomieniu powyższego kodu VBA.


Powiązane artykuły:


Najlepsze narzędzia biurowe

Kutools for Excel rozwiązuje większość twoich problemów i zwiększa wydajność o 80%

  • Ponowne użycie: Szybko włóż złożone wzory, wykresy i wszystko, czego używałeś wcześniej; Szyfruj komórki z hasłem; Utwórz listę mailingową i wysyłaj e-maile ...
  • Pasek Super Formula (łatwo edytować wiele wierszy tekstu i formuły); Układ do czytania (łatwe odczytywanie i edytowanie dużej liczby komórek); Wklej do filtrowanego zakresu...
  • Scal komórki / wiersze / kolumny bez utraty danych; Podziel zawartość komórek; Połącz zduplikowane wiersze / kolumny... Zapobiegaj zduplikowanym komórkom; Porównaj zakresy...
  • Wybierz Duplikat lub Unikalny Wydziwianie; Wybierz puste wiersze (wszystkie komórki są puste); Super Find i Fuzzy Find w wielu zeszytach ćwiczeń; Losowy wybór ...
  • Dokładna kopia Wiele komórek bez zmiany odwołania do formuły; Automatyczne tworzenie odniesień do wielu arkuszy; Wstaw punktory, Pola wyboru i nie tylko ...
  • Wyodrębnij tekst, Dodaj tekst, Usuń według pozycji, Usuń przestrzeń; Tworzenie i drukowanie podsumowań stronicowania; Konwertuj zawartość komórek i komentarze...
  • Super filtr (zapisz i zastosuj schematy filtrów do innych arkuszy); Zaawansowane sortowanie według miesiąca / tygodnia / dnia, częstotliwości i innych; Specjalny filtr pogrubieniem, kursywą ...
  • Połącz skoroszyty i arkusze robocze; Scal tabele na podstawie kluczowych kolumn; Podziel dane na wiele arkuszy; Konwersja wsadowa xls, xlsx i PDF...
  • Ponad 300 zaawansowanych funkcji. Obsługuje Office / Excel 2007-2019 i 365. Obsługuje wszystkie języki. Łatwe wdrażanie w przedsiębiorstwie lub organizacji. Pełne funkcje 30-dniowy bezpłatny okres próbny. 60-dniowa gwarancja zwrotu pieniędzy.
karta kte 201905

Karta Office wprowadza interfejs z zakładkami do pakietu Office i znacznie ułatwia pracę

  • Włącz edycję i czytanie na kartach w programach Word, Excel, PowerPoint, Publisher, Access, Visio i Project.
  • Otwieraj i twórz wiele dokumentów w nowych kartach tego samego okna, a nie w nowych oknach.
  • Zwiększa produktywność o 50% i zmniejsza setki kliknięć myszą każdego dnia!
officetab dół
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.
    j.eri.cely · 10 days ago
    Hi, a question i have a Macro and i feed this file with another file then i need:

    1. Allow Copy  the external file and copy in my macro
    2. Prevent Copy in my macro and paste to external file is posible?
  • To post as a guest, your comment is unpublished.
    Amrit Subedi · 3 months ago
    Hello!
    I am trying to disable cut/paste tool in MS excel 2016 not the copy/paste tool. Can you give an idea?
    Thanks in advance!
  • To post as a guest, your comment is unpublished.
    la.king727@gmail.com · 1 years 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 · 1 years 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 · 1 years 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 · 1 years ago
    I used this code & want to Re-enable again? how to re-enable it?
  • 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.
      crystal · 1 years ago
      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.
    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 · 2 years ago
    THANKS SIR
  • 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.
      crystal · 2 years ago
      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.
    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.
    garak0410 · 3 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 · 3 years ago
      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.
        garak0410 · 3 years ago
        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.
    Linda · 3 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.
      crystal · 3 years ago
      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.
    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
      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.
        ERCA · 3 years ago
        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.
          crystal · 3 years ago
          Good day,
          The code works well in my case. May I know your Office version?
  • 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.
      crystal · 3 years ago
      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.
    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.
      crystal · 3 years ago
      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.
        mags · 3 years ago
        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.
          crystal · 3 years ago
          Good Day,
          The VBA1in above comment is the replacement of the original code.
  • To post as a guest, your comment is unpublished.
    martinkunder1988@gmail.com · 4 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 · 4 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.
      sa · 3 years ago
      have you found an answer?
  • To post as a guest, your comment is unpublished.
    rafhtaher · 4 years ago
    i do as above but the function of cut copy and past disabled in any excel file i open .why?
    • To post as a guest, your comment is unpublished.
      Stuart Davis · 2 years ago
      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!