Hi All
I have found the solution, for anyone interested here is the code to copy a formatted string obtained via the EA object model as a property to the Windows Clipboard, so that the formatting is preserved when written to a Word document
private void copyToClipBoardAsHTML(string text)
{
Encoding enc = Encoding.UTF8;
string begin = "Version:0.9\r\nStartHTML:{0:000000}\r\nEndHTML:{1:000000}"
+ "\r\nStartFragment:{2:000000}\r\nEndFragment:{3:000000}\r\n";
string htmlBegin = "<html>\r\n<head>\r\n"
+ "<meta http-equiv=\"Content-Type\""
+ " content=\"text/html; charset=" + enc.WebName + "\">\r\n"
+ "<title>HTML clipboard</title>\r\n</head>\r\n<body>\r\n"
+ "<!--StartFragment-->";
string htmlEnd = "<!--EndFragment-->\r\n</body>\r\n</html>\r\n";
string beginSample = String.Format(begin, 0, 0, 0, 0);
int countBegin = enc.GetByteCount(beginSample);
int countHTMLBegin = enc.GetByteCount(htmlBegin);
int countHTML = enc.GetByteCount(text);
int countHTMLEnd = enc.GetByteCount(htmlEnd);
string htmlTotal = String.Format(
begin,
countBegin,
countBegin + countHTMLBegin + countHTML + countHTMLEnd,
countBegin + countHTMLBegin,
countBegin + countHTMLBegin + countHTML) + htmlBegin + text + htmlEnd;
DataObject obj = new DataObject();
obj.SetData(DataFormats.Html, new System.IO.MemoryStream(
enc.GetBytes(htmlTotal)));
Clipboard.SetDataObject(obj, true);
}
Cheers