Option Explicit
Sub ChangeCopy()
Dim CmdBar As CommandBar
Dim CmdCtl As CommandBarControl
For Each CmdBar In CommandBars
Set CmdCtl = CmdBar.FindControl(ID:=19, recursive:=True)
If Not CmdCtl Is Nothing Then CmdCtl.OnAction = "CustomCopy"
Next CmdBar
Set CmdBar = Nothing
Set CmdCtl = Nothing
End Sub
Sub ResetCopy()
Dim CmdBar As CommandBar
Dim CmdCtl As CommandBarControl
For Each CmdBar In CommandBars
Set CmdCtl = CmdBar.FindControl(ID:=19, recursive:=True)
If Not CmdCtl Is Nothing Then CmdCtl.OnAction = ""
Next CmdBar
Set CmdBar = Nothing
Set CmdCtl = Nothing
End Sub
Sub CustomCopy()
MsgBox "You tried to copy the data, that request has been canceled", vbCritical, "Copy Canceled"
End Sub
|