Thứ Năm, 25 tháng 10, 2012

Tự động chuyển thành paste special khi nhấn CTRL + V (hoặc paste)

Nhiều lúc, một file excel (share) hoặc dùng chung. nhiều người copy & Paste làm hỏng hết format
Đoạn code sau (sưu tầm của bác NDU - GPE) bỏ vô module là vô hiệu hóa paste (chỉ cho phép paste special)
Sub PasteValue()
  Selection.PasteSpecial 3
End Sub

Sub Auto_Open()
  Application.OnKey "^v", "PasteValue"
  CommandBars.FindControl(Id:=22).OnAction = "PasteValue"
  CommandBars.FindControl(Id:=6002).Enabled = False
End Sub

Sub Auto_Close()
  Application.OnKey "^v"
  CommandBars("Cell").Reset
  CommandBars("Edit").Reset
  CommandBars.FindControl(Id:=6002).Enabled = True
 
End Sub

Không có nhận xét nào:

Đăng nhận xét