I am having a problem regarding clipboard and I get this error message every time I try to make a copy / paste operation from an Excel file.

The code breaks at Clipboard.GetDataObject() and the message error is this:

OpenClipboard Failed (Exception from HRESULT: 0x800401D0 (CLIPBRD_E_CANT_OPEN))

My WPF application is already running when I open Excel, write some text and then try to copy / paste.

The code that I'm using is this:

private void SetClipboardData() {
IDataObject data = Clipboard.GetDataObject();
IList result = GetDataForFileDropFormat( data );
if ( ( result != null ) && ( result.Count > 0 ) ) {
this._elementsClipboard = result;
this._sourceDrag = null;
this._sourceClipboard = null;

The above function is called in this handler method:

public void Handle_WM_DRAWCLIPBOARD( IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled ) {

SendMessage( this._nextClipboardViewer, msg, wParam, lParam );

// get data from clipboard

handled = true;

I have been searching MSDN and .NET forums, but didn't find a workaround for this issue.

Could someone help me with that or give me an idea of what should I try?