How to insert text from RTF to Word Document in c# -
i using winservice creating word docs.
problem have paste rtf word selection.
i have code:
private static void pastertf(object bookmarkname, office.application wordapplication, document worddocument, string rtftext, bool winservice) { if(bookmarkname == null || wordapplication == null || worddocument == null) return; if (!winservice) { clipboard.clear(); clipboard.settext(rtftext, textdataformat.rtf); idataobject formatedtext = clipboard.getdataobject(); if (formatedtext != null) { worddocument.bookmarks[bookmarkname].range.select(); selection sel = wordapplication.selection; sel.paste(); } clipboard.clear(); } else { ???? } }
do have idea how without using clipboard?
if rtf text (or word, or other compatible format) located in file, may use range.insertfile or bookmark.insertfile method:
string filename = "c:\\sales.docx"; object confirmconversions = false; object link = false; object attachment = false; bookmark1.insertfile(filename, ref missing, ref confirmconversions, ref link, ref attachment);
Comments
Post a Comment