Hi yoelyfie,
after experimenting with the code and running into errors, I kept receiving "Out of Memory" messages on normal Copy&Paste actions in the editor. It helped to call CloseClipboard to properly close the Clipboard.