title: Clipboard opening failed
body: <p>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.</p>
  
  <p>The code breaks at <code>Clipboard.GetDataObject()</code> and the message error is this:</p>
  
  <pre><code>OpenClipboard Failed (Exception from HRESULT: 0x800401D0 (CLIPBRD_E_CANT_OPEN))
  </code></pre>
  
  <p>My WPF application is already running when I open Excel, write some text and then try to copy / paste. </p>
  
  <p>The code that I'm using is this:</p>
  
  <pre><code>private void SetClipboardData()
  {
      IDataObject data = Clipboard.GetDataObject();
      IList result = GetDataForFileDropFormat( data );
  
      if ( ( result != null ) &amp;&amp; ( result.Count &gt; 0 ) )
      {
          this._elementsClipboard = result;
          this._sourceDrag = null;
          this._sourceClipboard = null;
      }
  }
  </code></pre>
  
  <p>The above function is called in this handler method:</p>
  
  <pre><code>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
      SetClipboardData();
  
      handled = true;
  }
  </code></pre>
  
  <p>I have been searching MSDN and .NET forums, but didn't find a workaround for this issue.</p>
  
  <p>Could someone help me with that or give me an idea of what should I try?</p>
  
  <p>Thanks!</p>