RichTextBox displays images and the code for word

  • 2020-05-26 08:16:43
  • OfStack

Display image:


        Image img = Image.FromFile( @"E:\image\bottle\2006122013203825344.jpg" );          
 Clipboard.SetDataObject( img );          
 RichTextBox.Paste( DataFormats.GetFormat( DataFormats.Bitmap ) );
 According to word
string filename = @"d:\ essays .doc";    
//C# read word Instantiation of a file COM         
Microsoft.Office.Interop.Word.ApplicationClass wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();     
object fileobj = filename;          
object nullobj = System.Reflection.Missing.Value;      // Open the specified file (different version) COM The number of parameters is different, 1 Generally speaking, divide by number 1 Outside in nullobj Line)       
Microsoft.Office.Interop.Word.Document doc =            wordApp.Documents.Open( ref fileobj, ref nullobj, ref nullobj,          ref nullobj, ref nullobj, ref nullobj,           ref nullobj, ref nullobj, ref nullobj,         ref nullobj, ref nullobj, ref nullobj,            ref nullobj, ref nullobj, ref nullobj, ref nullobj );            // achieve doc Text in a file             
ResponseFormsMediator.RemindersRichTextBox.Text += doc.Content.Text;      //C# read word Close file for file              
doc.Close( ref nullobj, ref nullobj, ref nullobj );            //C# read word File closure COM              wordApp.Quit( ref nullobj, ref nullobj, ref nullobj );


Related articles: