title: How can I copy an array to clipboard in excel vba
body: <p>I'm currently looking for a methode to copy a 1D array to clipboard by using excel vba. So far, I already fail by copying only one string to the clipboard. What I did is: </p>
  
  <p>First: I included the "Microsoft Forms 2.0 Object Library" to my project</p>
  
  <p>Second: I tried to copy the strText string to the clipboard by using the following code. </p>
  
  <pre><code>Sub copyToClipboard()
     Dim objData As New MSForms.DataObject       
     strText= "1"
     objData.SetText strText
     objData.PutInClipboard
  
     objData.GetFromClipboard
     resultString = objData.GetText
  End Sub
  </code></pre>
  
  <p>If I paste the clipboard to a text Editor I get some funny symbols. If I check the content of resultString, I get "??".</p>
  
  <hr>
  
  <p>EDIT: As mentionded below, I only get the "??" if I debug the code. A normal run is giving the expected output. Here is an image of the output window<a href="https://i.stack.imgur.com/fEFxg.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fEFxg.jpg" alt="The second output line is while debuging the code, the first one is a normal run"></a></p>
  
  <p>The second output line is while debuging the code, the first one is a normal run.</p>