如何在excel中检测粘贴事件 [英] how to detect paste event in excel

查看:687
本文介绍了如何在excel中检测粘贴事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要检测excel的粘贴命令。是否有任何工作可以告诉我们,当用户点击菜单上的粘贴从左边的mosue按钮点击弹出。如果用户单击粘贴菜单项,这需要我执行一个过程。任何帮助将不胜感激。

I need to detect paste command of excel. Is there any work around which can tell us when user click the paste on the menu pop up from the left mosue button click. This is required me to execute a procedure if user click the paste menu item. Any help would be appreciated.

Regards,
Amit

Regards, Amit

推荐答案

Excel VBA借用如何检测工作表中是否粘贴了某些内容

从这个事件的内部开始, Workbook_SheetChange 事件将触发页面上的任何更改事件,您可以通过查看撤消列表历史记录中的最新条目来检查最后一次更改是否已粘贴:

From inside this event, you can then check if the last change was a paste by looking at the most recent entry in the Undo List History:

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
  Dim lastAction As String

  ' Get the last action performed by user
  lastAction = Application.CommandBars("Standard").Controls("&Undo").List(1)

  ' Check if the last action was a paste
  If Left(lastAction, 5) = "Paste" Then

    ' Do Stuff Here

  End If
End Sub

这篇关于如何在excel中检测粘贴事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆