![]() |
Capturing Excel Copy/Paste/Cut events
Hello:
Im developing an application for Excel with C#. I need to do some custom actions when the user does a Copy, Cut or Paste in the workbook. Is there anyway to capture those Excel Events, if so how? Thanks in advance, Ram |
Capturing Excel Copy/Paste/Cut events
Hi
I have navigated through all the events of the Excel Object Modal in the help file below, we can not find such an event will be fired when copy/cut/paste. You may find that Excel Whole Object Modal reference here. <Program Files\Microsoft Office\OFFICE11\1033\VBAXL10.CHM Best regards, Peter Huang Microsoft Online Partner Support Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties, and confers no rights. |
Capturing Excel Copy/Paste/Cut events
Hello Peter:
Thanks for your response! Yes, youre right there are no such events in the Excel Object Model. What I was wondering is if there's any workaround that allows to respond to this user actions? Thanks again! Ram ""Peter Huang" [MSFT]" wrote: Hi I have navigated through all the events of the Excel Object Modal in the help file below, we can not find such an event will be fired when copy/cut/paste. You may find that Excel Whole Object Modal reference here. <Program Files\Microsoft Office\OFFICE11\1033\VBAXL10.CHM Best regards, Peter Huang Microsoft Online Partner Support Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties, and confers no rights. |
Capturing Excel Copy/Paste/Cut events
Hi
I am researching the issue and reply to you ASAP. Best regards, Peter Huang Microsoft Online Partner Support Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties, and confers no rights. |
Capturing Excel Copy/Paste/Cut events
Hi
Based on my reseach, Excel did not expose Key_Down similar event for us to handle. So I think it is hard to track the copy/paste/cut. Although we can write a keyboard hook to handle all the keyboard, but that may destroy the Excel application's stability. If you still have any concern, I think you may try contact MSPSS directly to see if there is any better solution. Thanks for your understanding! Best regards, Peter Huang Microsoft Online Partner Support Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties, and confers no rights. |
Capturing Excel Copy/Paste/Cut events
you can use the Application.Worksheet_Change event to capture pasting
cells, but a more complete solution is to use the Application.Onkey function and rewrite cut/copy/paste key shortcuts. Since in Excel(2000 and higer) you can also capture events from commandbuttons you could aslo hook your code to the cut/copy/paste buttons so you also cover that route. Nasty, but should be workable. remember that excel cannot do anything while in cell editing mode, so cutting/copying/pasting *inside* a cell cannot be detected from an app running inside the Excel thread. Any code that needs to act on cell text(I'm not sure you need it) needs to be out of process using subclassing and window hooks(brrr). You did not write which clipboard formats you wanted to act upon, but I suspect Ranges is your primary concern. DM Unseen |
Capturing Excel Copy/Paste/Cut events
Thanks to both for the responses!
- Ram "DM Unseen" wrote: you can use the Application.Worksheet_Change event to capture pasting cells, but a more complete solution is to use the Application.Onkey function and rewrite cut/copy/paste key shortcuts. Since in Excel(2000 and higer) you can also capture events from commandbuttons you could aslo hook your code to the cut/copy/paste buttons so you also cover that route. Nasty, but should be workable. remember that excel cannot do anything while in cell editing mode, so cutting/copying/pasting *inside* a cell cannot be detected from an app running inside the Excel thread. Any code that needs to act on cell text(I'm not sure you need it) needs to be out of process using subclassing and window hooks(brrr). You did not write which clipboard formats you wanted to act upon, but I suspect Ranges is your primary concern. DM Unseen |
Capturing Excel Copy/Paste/Cut events
Hi
You are welcome! Also thanks for Ram's knowledge sharing in the community! Best regards, Peter Huang Microsoft Online Partner Support Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties, and confers no rights. |
Capturing Excel Copy/Paste/Cut events
Ram,
Not sure if it is workable for you, but if you share the workbook, can you monitor the change history ? Won't catch a copy though. NickHk "RNG" wrote in message ... Thanks to both for the responses! - Ram "DM Unseen" wrote: you can use the Application.Worksheet_Change event to capture pasting cells, but a more complete solution is to use the Application.Onkey function and rewrite cut/copy/paste key shortcuts. Since in Excel(2000 and higer) you can also capture events from commandbuttons you could aslo hook your code to the cut/copy/paste buttons so you also cover that route. Nasty, but should be workable. remember that excel cannot do anything while in cell editing mode, so cutting/copying/pasting *inside* a cell cannot be detected from an app running inside the Excel thread. Any code that needs to act on cell text(I'm not sure you need it) needs to be out of process using subclassing and window hooks(brrr). You did not write which clipboard formats you wanted to act upon, but I suspect Ranges is your primary concern. DM Unseen |
All times are GMT +1. The time now is 11:55 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com