# Not understanding when and why CopyToClipboard works and doesn't work with CDF documents

My objective is to obtain results from calculations in a CDF document that can be used elsewhere (in an R script, Excel, etc.) without having to type the results in by hand. I understand that writing to a file is not allowed for CDF documents.

The following in a CDF document copies a list of strings just fine to the clipboard:

Manipulate[z = Table[ToString[i], {i, n}],
{n, 1, 100, 1, Appearance -> "Labeled"},
Button["Copy results to clipboard", CopyToClipboard[z]]]


But the following in a CDF document does not produce anything in the clipboard:

Manipulate[z = "n = " <> ToString[n] <> "\nn2 = " <> ToString[n + 2],
{n, 1, 100, 1, Appearance -> "Labeled"},
Button["Copy results to clipboard", CopyToClipboard[z]]]


I'm using Mathematica 10.2 and CDF Player 10.3 on a Windows 7 PC and both scripts work in Mathematica. It's just the second one that doesn't work in the CDF Player.

Any suggestions (including those that avoid the clipboard approach) would be greatly appreciated.

• Many FronEnd related functions are not available in CDF, that's probably another one. – Kuba Nov 4 '15 at 19:45
• Further attempts seem to indicate that lists are copied to the clipboard but single strings are not. Surrounding z in the second example with curly brackets gets the information into the clipboard but the curly brackets are included and longer substrings are split. I'm still looking for a cleaner way to create code in the CDF that can be made available to another application. – JimB Nov 4 '15 at 20:30