0
votes

I am facing a very weird problem in Excel. I have overridden the CTRL+C and CTRL+V keys and on copy, I put my custom DataObject on the clipboard that contains both the Excel formats and my custom formats.

I copy my data to the clipboard and it gets copied without any problem. I can also see it in the Office Clipboard. Now I copy some text from outside Excel (from Notepad) and try to paste it in Excel but Excel pastes the previous data that I copied from Excel sheet. I am pasting using Worksheet.Paste(...) method.

After pasting a number of times, Excel starts pasting the new data but it is not fixed. Sometimes I do not see the new data at all although the Windows Clipboard Viewer and Office Clipboard both show the new data as soon as I copy from notepad.

Any idea why Office takes time to paste this new data?

1
Um, why would you override such basic hotkeys? In just about any situation I can think of, that would only confuse the end-user and give very little benefit.PowerUser
My add-in creates and works on its own worksheet and custom data. The CTRL+C and CTRL+V handlers let the add-in handle custom data. An example is copy-paste of pictures that are linked to a cell.A9S6
Are you correctly closing the Clipboard? What programming language are you in? Is it possible that you are using .NET and close the Clipboard in the finalizer ("destructor") of an object?Dirk Vollmar
@0xA3: I am not calling any CloseClipboard(...) method. I am using C# and using the Clipboard class, it does not have any close clipboard method.A9S6

1 Answers

0
votes

Excel would rather paste from its own internal buffer than the clipboard, so it only looks at the clipboard if it has reason to believe that it has changed. If you are interfering with the clipboard notification chain, it may not know about the updates. Or it may only check for clipboard updates if it loses/gains focus. i.e. if Excel still has focus and your add-on copies something to the clipboard in the background, it has no reason to think that it needs to look at the clipboard.