Here is one solution, catching all possibilities of Pasting.
To enable special pasting, run SetMyPaste
To reset to normal pasting, run: ResetMyPaste
HTH
--
AP
'------------------------
Option Explicit
Sub SetMyPaste()
SetAllPaste (True)
End Sub
Sub ResetMyPaste()
SetAllPaste (False)
End Sub
Private Sub SetAllPaste(bSet As Boolean)
Dim aCb As Variant
Dim iCb As Integer
aCb = Array("Standard", "Edit", "Cell")
For iCb = LBound(aCb) To UBound(aCb)
setPaste aCb(iCb), bSet
Next iCb
If bSet Then
Application.OnKey "^v", "MyPaste"
Else
Application.OnKey "^v"
End If
End Sub
Private Sub setPaste(sCb As Variant, bSet As Boolean)
Const iIdPaste = 22
Dim cbcControl As CommandBarControl
For Each cbcControl In CommandBars(sCb).Controls
With cbcControl
If .ID = iIdPaste Then
If bSet Then
.OnAction = "MyPaste"
Else
.Reset
End If
Exit For
End If
End With
Next cbcControl
End Sub
Private Sub MyPaste()
If Application.CutCopyMode Then
Selection.PasteSpecial Paste:=xlPasteValues
End If
End Sub
'-------------------------------
"srinu1264" <
[email protected]> a écrit
dans le message de (e-mail address removed)...