提示:其他語言是Google翻譯的。 你可以訪問 English 版本。
登入
x
or
x
x
註冊
x

or

如何在Excel中禁用剪切,複製和粘貼功能?

假設你有一個重要數據的工作簿,你需要防止被剪切,複製和粘貼。 如何實現它? 本文提供了一種VBA方法,可以在Excel工作簿中同時禁用剪切,複製和粘貼功能。

使用VBA代碼禁用剪切,複製和粘貼功能

Office選項卡在Office中啟用選項卡式編輯和瀏覽,使您的工作更輕鬆......
Kutools for Excel解決了您的大多數問題,並使您的生產率提高了80%
  • 重用任何東西: 將最常用或最複雜的公式,圖表和其他任何內容添加到您的收藏夾中,並在將來快速重複使用它們。
  • 超過20文本功能: 從文本字符串中提取數字; 提取或刪除部分文字; 將數字和貨幣轉換為英文單詞。
  • 合併工具:將多個工作簿和工作表合二為一; 合併多個單元格/行/列,而不會丟失數據; 合併重複的行和總和。
  • 拆分工具:根據價值將數據分割成多個工作表; 一本工作簿可轉換為多個Excel,PDF或CSV文件; 一列到多列。
  • 粘貼跳過 隱藏/過濾行; 數和總和 按背景顏色; 將個性化電子郵件批量發送給多個收件人。
  • 超級過濾器: 創建高級過濾方案並應用於任何工作表; 分類 按週,日,頻率等; 過濾 通過大膽,公式,評論......
  • 超過300強大的功能; 與Office 2007-2019和365一起使用; 支持所有語言; 在您的企業或組織中輕鬆部署。

箭頭藍色右泡使用VBA代碼禁用剪切,複製和粘貼功能


請按照以下步驟在Excel工作簿中禁用剪切,複製和粘貼功能。

1。 在工作簿中,您需要禁用剪切,複製和粘貼功能,請按下 其他 + F11 鍵同時打開 Microsoft Visual Basic for Applications 窗口。

2。 在裡面 Microsoft Visual Basic for Applications 窗口,請雙擊 的ThisWorkbook 在左邊 個項目 窗格,然後將下面的VBA代碼複製並粘貼到 ThisWorkbook(Code) 窗口。 看截圖:

VBA代碼:在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。 那麼請按下 其他 + Q 鍵退出 Microsoft Visual Basic for Applications 窗口。

現在,您無法從此工作簿中剪切或複制數據,同時,從其他工作表或工作簿中復制的數據無法粘貼到此工作簿中。

備註:運行上述VBA代碼後,拖放功能也被禁用。


箭頭藍色右泡相關文章:


Kutools for Excel解決了您的大多數問題,並使您的生產率提高了80%

  • 重用: 快速插入 複雜的公式,圖表 以及你以前用過的任何東西; 加密單元格 密碼; 創建郵件列表 並發送電子郵件...
  • 超級方程式酒吧 (輕鬆編輯多行文字和公式); 閱讀佈局 (輕鬆讀取和編輯大量單元格); 粘貼到過濾範圍...
  • 合併單元格/行/列 不丟失數據; 分裂細胞含量; 組合重複的行/列...防止重複的細胞; 比較範圍...
  • 選擇複製或唯一 行; 選擇空行 (所有細胞都是空的); 超級查找和模糊查找 在許多工作簿中; 隨機選擇......
  • 精確複製 多個單元格而不更改公式參考; 自動創建參考 多張表; 插入項目符號,複選框等等......
  • 提取文本,添加文本,按位置刪除, 刪除空間; 創建和打印分頁小計; 在單元格內容和註釋之間轉換...
  • 超級過濾器 (將過濾方案保存並應用到其他工作表); 高級排序 按月/週/日,頻率等; 特殊過濾器 用粗體,斜體......
  • 結合工作簿和工作表; 根據鍵列合併表; 將數據拆分為多個表格; 批量轉換xls,xlsx和PDF...
  • 超過300強大的功能。 支持Office / Excel 2007-2019和365。 支持所有語言。 在您的企業或組織中輕鬆部署。 全功能30天免費試用。
kte tab 201905

Office選項卡為Office提供選項卡式界面,使您的工作更輕鬆

  • 在Word,Excel,PowerPoint中啟用選項卡式編輯和閱讀,Publisher,Access,Visio和Project。
  • 在同一窗口的新選項卡中打開並創建多個文檔,而不是在新窗口中。
  • 通過50%提高您的工作效率,每天為您減少數百次鼠標點擊!
官方底部
Say something here...
symbols left.
You are guest ( Sign Up? )
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.
    Apolo · 2 months ago
    Thank you, very useful.
  • To post as a guest, your comment is unpublished.
    RAHUL MODI · 5 months ago
    THANKS SIR
  • To post as a guest, your comment is unpublished.
    RN PK · 8 months ago
    Thanks it works perfect ....can it be applied on a range only somehow?
  • To post as a guest, your comment is unpublished.
    Sam · 10 months ago
    It really works well, thanks a lot.
  • To post as a guest, your comment is unpublished.
    Vic · 10 months 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 · 1 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 · 1 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 · 1 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 · 1 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 · 1 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 · 1 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 · 1 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 · 1 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 · 1 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 · 1 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 Pvt Ltd · 1 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 · 1 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 · 2 years ago
    How to enable the cut, copy and paste function back? Please advice!
    • To post as a guest, your comment is unpublished.
      crystal · 1 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 · 1 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 · 1 years ago
          Good Day,
          The VBA1in above comment is the replacement of the original code.
  • To post as a guest, your comment is unpublished.
    Martin · 2 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 · 2 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 · 1 years ago
      have you found an answer?
  • To post as a guest, your comment is unpublished.
    rafhtaher · 2 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 · 5 months 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!