BradleyOng83
Member
- Joined
- Mar 2, 2006
- Messages
- 19
- Programming Experience
- Beginner
how to open word(microsoft word) to richtextbox in vb.net? i just know open word use vb.net only
Dim app As Word.Application = New Word.ApplicationClass()
'Refs to pass to the Open method for parameters we're not interested in.
Dim Nothingobj As Object = System.Reflection.Missing.Value
'Full file path.
Dim file As Object = "C:\MyDoc.doc"
Word.Document doc = app.Documents.Open(
file, Nothingobj, Nothingobj,
Nothingobj, Nothingobj, Nothingobj,
Nothingobj, Nothingobj, Nothingobj,
Nothingobj, Nothingobj, Nothingobj,
Nothingobj, Nothingobj, Nothingobj)
'Select and copy text to clipboard.
doc.ActiveWindow.Selection.WholeStory()
doc.ActiveWindow.Selection.Copy()
Dim data As IDataObject = Clipboard.GetDataObject()
'Do whatever with the text.
Dim text As String = data.GetData(DataFormats.Text).ToString()
Console.WriteLine(text)
'Close doc and shutdown Word application.
doc.Close( Nothingobj, Nothingobj, Nothingobj)
app.Quit( Nothingobj, Nothingobj, Nothingobj)