Hi friends !
I want to read a worddoc into a richtextbox but when I do it like the followingThe wordApplication opens and closes which looks terrible.Code:public void ReadWordStream(string path) { ApplicationClass wordApp = new ApplicationClass(); object file = path; object readOnly = false; object isVisible = false; object missing = System.Reflection.Missing.Value; wordApp.WindowState = WdWindowState.wdWindowStateMinimize; wordApp.Visible = false; Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(ref file, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing); wordApp.Visible = false; doc.ActiveWindow.Selection.WholeStory(); string text = doc.ActiveWindow.Selection.Text; doc.ActiveWindow.Selection.Copy(); IDataObject data = Clipboard.GetDataObject(); rtbDoc.Paste(); object boolObj = (object)false; wordApp.Documents.Close(ref boolObj, ref boolObj, ref boolObj); wordApp.Quit(ref boolObj, ref boolObj, ref boolObj); }
Is there a way to read out the text within formating to my RTB without opening the word Application. ( It's word 2003 ) As you can see I tried to minimize, I tried to get visible to false. Maybe there is a way to access the word document without opening word ?application




Jonny Poet
Reply With Quote