This question already has an answer here:
这个问题在这里已有答案:
- Excel VBA How to detect if something was pasted in a Worksheet 2 answers
- Excel VBA如何检测工作表2中是否粘贴了某些内容
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.
我需要检测excel的paste命令。有没有任何工作可以告诉我们当用户点击菜单上的粘贴时,从左边的按钮点击弹出。如果用户单击粘贴菜单项,则需要我执行该过程。任何帮助,将不胜感激。
Regards, Amit
此致,阿米特
1 个解决方案
#1
12
Borrowing from Excel VBA How to detect if something was pasted in a Worksheet. The Workbook_SheetChange
event will fire for any change event on the page, including a paste.
借用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
#1
12
Borrowing from Excel VBA How to detect if something was pasted in a Worksheet. The Workbook_SheetChange
event will fire for any change event on the page, including a paste.
借用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