Gå til hovedindhold

Hvordan deaktiveres klip, kopi og indsæt funktioner i Excel?

Antag at du har en projektmappe med vigtige data, som du skal beskytte mod at blive klippet, kopieret og indsat. Hvordan opnås det? Denne artikel indeholder en VBA-metode, som du kan deaktivere funktionerne for klipning, kopiering og indsættelse på samme tid i en Excel-projektmappe.

Deaktiver klip, kopier og indsæt funktioner med VBA-kode


Deaktiver klip, kopier og indsæt funktioner med VBA-kode

Gør som følger for at deaktivere klip, kopier og indsæt funktionerne i en Excel-projektmappe.

1. I projektmappen skal du deaktivere funktionerne til klipning, kopiering og indsættelse. Tryk på andre + F11 taster samtidigt for at åbne Microsoft Visual Basic til applikationer vindue.

2. i Microsoft Visual Basic til applikationer dobbeltklik på vinduet ThisWorkbook til venstre Projekt og derefter kopiere og indsætte nedenstående VBA-kode i Denne arbejdsbog (kode) vindue. Se skærmbillede:

VBA-kode: Deaktiver funktionerne for klipning, kopiering og indsættelse på samme tid i 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. Tryk derefter på andre + Q taster for at afslutte Microsoft Visual Basic til applikationer vindue.

Nu kan du ikke klippe eller kopiere data fra denne projektmappe, i mellemtiden kan data, du har kopieret fra andre ark eller projektmapper, ikke indsættes i denne projektmappe.

Bemærk: Træk og slip-funktionen er også deaktiveret efter at have kørt ovenstående VBA-kode.


Relaterede artikler:

Bedste kontorproduktivitetsværktøjer

🤖 Kutools AI Aide: Revolutionér dataanalyse baseret på: Intelligent udførelse   |  Generer kode  |  Opret brugerdefinerede formler  |  Analyser data og generer diagrammer  |  Aktiver Kutools funktioner...
Populære funktioner: Find, fremhæv eller identificer dubletter   |  Slet tomme rækker   |  Kombiner kolonner eller celler uden at miste data   |   Runde uden formel ...
Super opslag: VLookup med flere kriterier    Multiple Value VLookup  |   VOpslag på tværs af flere ark   |   Fuzzy Lookup ....
Avanceret rulleliste: Opret hurtigt rulleliste   |  Afhængig rulleliste   |  Multivælg rulleliste ....
Column Manager: Tilføj et bestemt antal kolonner  |  Flyt kolonner  |  Skift synlighedsstatus for skjulte kolonner  |  Sammenlign områder og kolonner ...
Fremhævede funktioner: Grid fokus   |  Designvisning   |   Stor Formel Bar    Arbejdsbog & Ark Manager   |  Ressourcebibliotek (Autotekst)   |  Datovælger   |  Kombiner regneark   |  Krypter/Dekrypter celler    Send e-mails efter liste   |  Superfilter   |   Specielt filter (filter fed/kursiv/gennemstreget...) ...
Top 15 værktøjssæt12 tekst Værktøjer (tilføje tekst, Fjern tegn, ...)   |   50 + Chart Typer (Gantt kort, ...)   |   40+ Praktisk formler (Beregn alder baseret på fødselsdag, ...)   |   19 Indsættelse Værktøjer (Indsæt QR-kode, Indsæt billede fra sti, ...)   |   12 Konvertering Værktøjer (Tal til ord, Valutaomregning, ...)   |   7 Flet og del Værktøjer (Avancerede kombinere rækker, Opdel celler, ...)   |   ... og mere

Overlad dine Excel-færdigheder med Kutools til Excel, og oplev effektivitet som aldrig før. Kutools til Excel tilbyder over 300 avancerede funktioner for at øge produktiviteten og spare tid.  Klik her for at få den funktion, du har mest brug for...

Beskrivelse


Fanen Office bringer en grænseflade til et kontor med Office, og gør dit arbejde meget lettere

  • Aktiver redigering og læsning af faner i Word, Excel, PowerPoint, Publisher, Access, Visio og Project.
  • Åbn og opret flere dokumenter i nye faner i det samme vindue snarere end i nye vinduer.
  • Øger din produktivitet med 50 % og reducerer hundredvis af museklik for dig hver dag!
Comments (51)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
è possível realizar apenas em uma linha ou coluna específica?
This comment was minimized by the moderator on the site
Hi RAPHAEL,
If you only want to disable the Cut, Copy and Paste options in a certian column or row, the following VBA codes can help.
1. Open the worksheet (such as Sheet1) where you want to disable these options in a certian column or row, right click the sheet tab and click View Code from the right-clicking menu.
2. Copy the following VBA code to the Worksheet (Code) window.
Note: In the code, "Sheet1!$D:$D" stand for the sheet name and the column. You can change it to the sheet name and column of your own.
If you need to disable a row (such as row 3) in that worksheet, change $D:$D to 3:3.
Worksheet (Code) editor:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
    Dim Rg As Range
    Dim xRg As Range

    Set xRg = Range("Sheet1!$D:$D")
    Set Rg = Intersect(ActiveWindow.RangeSelection, xRg)
    If Rg Is Nothing Then
        Application.OnKey "^c"
    Else
        Application.CutCopyMode = False
        Application.OnKey "^c", ""
        Application.CellDragAndDrop = False
    End If

End Sub

3. Stay in the Visual Editor, double click ThisWorkbook in the left pane, and then copy the following code into the ThisWorkbook (code) window.
4. Press the Alt + Q keys to close the Visual Editor.
ThisWorkbook (Code) editor:

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
On Error Resume Next
    Dim Rg As Range
    Dim xRg As Range

    Set xRg = Range("Sheet1!$D:$D")
    Set Rg = Intersect(ActiveWindow.RangeSelection, xRg)
    If Rg Is Nothing Then
        Application.OnKey "^c"
    Else
        Application.CutCopyMode = False
        Application.OnKey "^c", ""
        Application.CellDragAndDrop = False
    End If


End Sub
This comment was minimized by the moderator on the site
É possível desabilitar a tecla de atalho ctrl+D?
This comment was minimized by the moderator on the site
I added the code but if I want to re-enable it how should I do it, please help immediately.
This comment was minimized by the moderator on the site
Just save it as a file without macros (.xlsx)
This comment was minimized by the moderator on the site
Hi! Is it possible to leave separate cells available for editing/copying/pasting but all the other cells on the same sheet should keep protected from all the actions mentioned before. If yes - how to do that? 
This comment was minimized by the moderator on the site
Is it possible to leave separate cells available for copying/pasting/editing? All the other cells on this sheet should be protected from the mentioned action
This comment was minimized by the moderator on the site
I have multiple sheet in my workbook & i want to use this code for one sheet only....i want to paste in worksheet module not in the workbook........can someone please modify it only for a worksheet
This comment was minimized by the moderator on the site
Hi, Shift to the worksheet where you want to disable the Cut, Copy And Paste Functions, right click the sheet tab and then copy and paste the VBA below into the Sheet (Code) window. Then the Cut, Copy And Paste functions will be disabled only in this sheet.<div data-tag="code">Private Sub Worksheet_Activate()
Application.CutCopyMode = False
Application.OnKey "^c", ""
Application.CellDragAndDrop = False
End Sub

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

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

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

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

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

Private Sub Worksheet_SheetDeactivate(ByVal Sh As Object)
Application.CutCopyMode = False
End Sub
This comment was minimized by the moderator on the site
Hi,
I tried this vba code for sheet 7 ( for example)
But it does not work on sheet 7 and only work when I copy a cell from the sheet 7 to another sheet so does not allow to paste in another sheet.
This comment was minimized by the moderator on the site
thnk u so much....it make my work very easy & also i learned ...thnks
This comment was minimized by the moderator on the site
I have multiple sheet in my workbook & i want to use this code for one sheet only...can someone please modify it only for a worksheet
This comment was minimized by the moderator on the site
hi sir, can you please change it only for worksheet
This comment was minimized by the moderator on the site
Is there a way to allow copy pasting on another workbook? The only thing I don't want is pasting in this workbook. Thank you
This comment was minimized by the moderator on the site
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?
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations