Group:  Microsoft Excel ยป microsoft.public.excel.interopoledde
Thread: Pasting RTF into Excel doesn't work

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Pasting RTF into Excel doesn't work
Joe 26.07.2006 19:10:02
I'm trying to get RTF text to display as formatted text in an Excel cell. I
put the text on the clipboard, select the destination cell and send the
application a CTR-V. I can see the proper cell being selected. When I hit the
SendKeys line, the system hangs until I do a CTR-ALT-DEL which brings up the
Task Manager.

I know the RTF string is in the clipboard and valid, as I can paste into
Word. If I try to manually paste into Excel after filling the clipboard, the
Paste and Paste Special menu items are greyed-out, as if it doesn't see
anything in the clipboard. Here is the code I'm using:

string dd = eRow["DRILLDOWNCOMMENT"].ToString();

Clipboard.Clear();

if (dd.Length > 0)
{
cellID = "AA" + row.ToString();
Excel.Range Range = worksheet.get_Range(cellID,
cellID);
Range.Select();
Clipboard.SetText(dd, TextDataFormat.Rtf);
string windowName = "Microsoft Excel - " +
fileName;
IntPtr hWnd = FindWindow(null, windowName);
SetForegroundWindow(hWnd);
SendKeys.SendWait("^V");
}

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net