Clipboard and CSV (CommaSeparatedValue) does not work

B

Bob

I am simply trying to write CSV data to the the clipboard. The code
below is not working. Any suggestions?

Dim data As New DataObject
Dim ms As New MemoryStream
Dim sw As New StreamWriter(ms)

sw.Write("Tom")
sw.Write(",")
sw.Write("Jones")
sw.Write(",")
sw.Write(100)
sw.WriteLine()
sw.Write(Chr(0))
sw.Close()

data.SetData(DataFormats.CommaSeparatedValue, ms)
Clipboard.SetDataObject(data, False)

ms.Close()

THANKS
Bob
 
C

ClayB [Syncfusion]

This seemed to work for me.

Dim data As New DataObject
Dim sb As New System.Text.StringBuilder
sb.Append("Tom")
sb.Append(",")
sb.Append("Jones")
sb.Append(",")
sb.Append("100")
sb.Append(Environment.NewLine)
'sb.Append(Chr(0))
data.SetData(DataFormats.CommaSeparatedValue, sb.ToString())
Clipboard.SetDataObject(data)

To retrieve it:
Me.TextBox1.Text =
Clipboard.GetDataObject().GetData(DataFormats.CommaSeparatedValue).ToString(
)

=================================
Clay Burch, .NET MVP

Visit www.syncfusion.com for the coolest tools
 
B

Bob

Clay thanks for the help. I tried your code and my clipboard viewer
displays the CSV data just fine. However, I can not past this into
Excel, Word, or Notepad. I am using CSV to alow some records to be
copied to other applications. Any further suggestions?

Again thanks,
Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top