HTML to Clipboard

  • Thread starter Robert Manookian
  • Start date
R

Robert Manookian

Can anybody show me how to place simple HTML into the clipboard that can be
copied to an office application? I've tried setting simple using the
following:
Dim strHTML As String = "<P>The <B><FONT
size='4'><U>Clipboard</U></FONT></B>" & _

"is <FONT size='5'>Cool!</FONT></P>"

' Place HTML version in DataObject

Dim myDataObject As New DataObject()

myDataObject.SetData(DataFormats.Html, strHTML)

' Now place myDataObject, and thus all formats on the Clipboard

Clipboard.SetDataObject(myDataObject, True)

Can not paste this HTML into Word or Excel.
 
P

Peter Rennie

When you copy some html from ie to paste into word/excel it has its special
format. Copy something from a web page and then use the following code to
look at it

IDataObject data = Clipboard.GetDataObject();
string blah = (string)data.GetData(System.Windows.Forms.DataFormats.Html);
Console.WriteLine(blah);

You will need to format your html like this for word etc.

Peter
 

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