Office clipboard takes time to show changes
I am facing a very weird pro开发者_Go百科blem 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?
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.
精彩评论