title: Copy text to clipboard with Excel 365 VBA
body: <p>I want to copy text to the Windows 10 clipboard ready for pasting with Ctrl+V into an appropriate external application.</p>
  
  <p>I found a promising answer I cannot get working:
  <a href="https://stackoverflow.com/questions/34630704/copy-variables-contents-to-clipboard-vba-excel-2013">Copy Variable&#39;s Contents to Clipboard VBA (Excel 2013)</a></p>
  
  <p>My simplified test code:</p>
  
  <pre><code>Sub TestCopyTextToVar()
  
  Dim myData As DataObject
  Dim Output As String
  Output = "abc"
  
  Set myData = New DataObject
  myData.SetText Output
  myData.PutInClipboard
  MsgBox (Output &amp; " Text has been copied")
  
  End Sub
  </code></pre>
  
  <p>MsgBox displays Output correctly as 'abc'.</p>
  
  <p>A paste into Notepad (or other apps, such as the intended application) displays nothing.</p>
  
  <p>TextPad displays two question marks '??'.</p>