title: Disable/Enable Copy Paste
body: <p>I have these two codes:</p>
  
  <p>The first is a macro to disable copy-paste:</p>
  
  <pre><code>Sub Desable_Copy()
  
      Dim oCtrl As Office.CommandBarControl
  
      For Each oCtrl In Application.CommandBars.FindControls(ID:=21)
          oCtrl.Enabled = False
      Next oCtrl
  
      For Each oCtrl In Application.CommandBars.FindControls(ID:=19)
          oCtrl.Enabled = False
      Next oCtrl
  
      Application.CellDragAndDrop = False
  End Sub
  
  Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
      With Application
          .CellDragAndDrop = False
          .CutCopyMode = False 'Clear clipboard
      End With
  End Sub
  </code></pre>
  
  <p>The second is a macro to enable copy-paste:</p>
  
  <pre><code>Sub Enable_Copy()
  
      Dim oCtrl As Office.CommandBarControl
  
      For Each oCtrl In Application.CommandBars.FindControls(ID:=21)
          oCtrl.Enabled = True
      Next oCtrl
  
      For Each oCtrl In Application.CommandBars.FindControls(ID:=19)
          oCtrl.Enabled = True
      Next oCtrl
  
      Application.CellDragAndDrop = True
  End Sub
  
  Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
      With Application
          .CellDragAndDrop = True
          .CutCopyMode = True 'Clear clipboard
      End With
  End Sub
  </code></pre>
  
  <p>When I execute the code I have an error message:</p>
  
  <blockquote>
    <p>Ambiguous Name Detected</p>
  </blockquote>