如何在丰富的文本框

问题描述:

喜开用图像和子弹word文件我是通过打开的对话框中打开了丰富的文本框中输入一个字的文件2007(.doc文件)。 它工作正常,但图像和项目符号不显示在富文本框中。 我要开个图像和子弹打开Word文件中的格式文本框。如何在丰富的文本框

我使用打开Word文件的代码,并将其转换一句判。

Microsoft.Office.Interop.Word.ApplicationClass wordObject = new Microsoft.Office.Interop.Word.ApplicationClass(); 
object File = txtfilepath.Text; //this is the path 
object nullobject = System.Reflection.Missing.Value; 
Microsoft.Office.Interop.Word.Application wordobject = new Microsoft.Office.Interop.Word.Application(); 
wordobject.DisplayAlerts = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone; 
Microsoft.Office.Interop.Word._Document docs = wordObject.Documents.Open(ref File, ref nullobject, ref nullobject, ref nullobject, 
       ref nullobject, ref nullobject, ref nullobject, ref nullobject, 
       ref nullobject, ref nullobject, ref nullobject, ref nullobject, 
       ref nullobject, ref nullobject, ref nullobject, ref nullobject); 
       docs.ActiveWindow.Selection.WholeStory(); 
       docs.ActiveWindow.Selection.Copy(); 
       IDataObject data = Clipboard.GetDataObject(); 
       rtbgermanfile.Text = data.GetData(DataFormats.Text).ToString(); 
       string name = rtbgermanfile.Text.Trim(); 
       name = String.Join(Environment.NewLine, name.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries)); 
       string newtext = name.Replace("\n\n", "\n"); 
       string newtext2 = newtext.Replace("\n\n", "\n"); 
       rtbgermanfile.Text = newtext2.ToString(); 
       txtwriteingerman.Text = rtbgermanfile.Lines[0]; 
       docs.Close(ref nullobject, ref nullobject, ref nullobject); 
       wordobject.Quit(ref nullobject, ref nullobject, ref nullobject); 
       //wordobject.Quit(SaveChanges:false, OriginalFormat: false, RouteDocument: false); 
       System.Runtime.InteropServices.Marshal.ReleaseComObject(wordobject); 

我不认为这很容易。如果我记得正确(可能是任何TextDataFormat类型),RTF或ANSI是富文本框的文本数据格式。我无法与ANSI交谈,但RTF不是一个好工具。

建议使用这个词本身。 http://msdn.microsoft.com/en-us/office2010developertrainingcourse_gettingstartedlab_topic3.aspx

但如果RTF看看这一个如何做到这一点的提示。 Programmatically adding Images to RTF Document