Hi!
I have a problem with special function 'PasteValues' are assigned to my regular paste functionality in Excel. It all works perfect as long as I stay in the same workbook but if I copy a value from a different workbook and try to paste this in the one where I have all my code NOTHING is being copied. I even at one point tried to access the clipboard but that didn't work either... I have tried several options and none works so help would be apprecciated. Here's what I have so far.
From my module:
Public Sub PasteValues()
Application.ScreenUpdating
= False
On Error Resume Next
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating
= True
End Sub
From Thisworkbook:
Private Sub Workbook_Activate()
Dim XLApp As Application
Set XLApp = Application
With XLApp
'Disable CUT
.CommandBars("Cell").FindC
ontrol(ID:
=21).Enabl
ed = False
.CommandBars("Row").FindCo
ntrol(ID:=
21).Enable
d = False
.CommandBars("Column").Fin
dControl(I
D:=21).Ena
bled = False
.CommandBars.FindControl(I
D:=21).Ena
bled = False
.CellDragAndDrop = True
.OnKey "^x", ""
.OnKey "^+X", ""
'Only paste values
.CommandBars("Cell").FindC
ontrol(ID:
=22).OnAct
ion = "PasteValues"
.CommandBars("Row").FindCo
ntrol(ID:=
22).OnActi
on = "PasteValues"
.CommandBars("Column").Fin
dControl(I
D:=22).OnA
ction = "PasteValues"
.CommandBars.FindControl(I
D:=22).OnA
ction = "PasteValues"
.CommandBars("Cell").FindC
ontrol(ID:
=755).Enab
led = False
.CommandBars("Row").FindCo
ntrol(ID:=
755).Enabl
ed = False
.CommandBars("Column").Fin
dControl(I
D:=755).En
abled = False
.CommandBars.FindControl(I
D:=755).En
abled = False
.OnKey "^v", "PasteValues"
.OnKey "^+V", "PasteValues"
End With
End Sub
Private Sub Workbook_Deactivate()
Dim XLApp As Application
Set XLApp = Application
With XLApp
'Restore Cut and Paste Special
.CellDragAndDrop = True
.CutCopyMode = True
.OnKey "^x"
.OnKey "^+X"
.CommandBars("Cell").Reset
.CommandBars("Row").Reset
.CommandBars("Column").Res
et
.CommandBars.FindControl(I
D:=21).Res
et
.CommandBars.FindControl(I
D:=22).Res
et
.CommandBars.FindControl(I
D:=755).Re
set
.OnKey "^v"
.OnKey "^+V"
End With
End Sub
Start Free Trial