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); 

range.insertfile method (word)
bookmark.insertfile method


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -