2012-02-08 101 views
1

喜開用圖像和子彈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); 

回答