views:

34

answers:

1

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?

A: 

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.

Chris Thornton
Yes, at one point I do interfere with the clipboard chain but I do call the next clipboard viewer in recommended way. I copy from notepad so Excel do lose focus. Is there a way to make Excel pick the latest one from clipboard OR to send a notification that clipboard data has changed?
A9S6