J
jabslim via DotNetMonster.com
i have used this code(see below) to open .doc files using a cmd button, an
open dialog box, a microsoft textbox(in COM components) to display the .doc
file and a texbox to display the pathname of the file, it can open the .doc
file but the display is all messy and the characters and spaces wont appear
right.
is there another way to open a .doc file within the form in vb.net and make
it appear the same as the format when opening it in MS WORD?? (like the
paragraphs, pages, fonts, etc)
------------------------------------------------------------------------------
-------------------------------------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.
EventArgs) Handles Button1.Click
Dim openFileDialog1 As New OpenFileDialog()
Dim file_doc As String
Dim di As New DirectoryInfo("c:\")
openFileDialog1.Title = "Please Select a File"
openFileDialog1.InitialDirectory = "c:\"
openFileDialog1.Filter = "ms word files (*.doc)|*.doc"
openFileDialog1.ShowDialog()
file_doc = openFileDialog1.FileName.ToString()
TextBox1.Text = file_doc 'pathname
Dim fs As New FileStream(file_doc, FileMode.Open, FileAccess.Read)
Dim sr As New StreamReader(fs)
sr.BaseStream.Seek(0, SeekOrigin.Begin)
While sr.Peek() > -1
AxTextBox1.MultiLine = True
AxTextBox1.Text &= sr.ReadLine()
End While
sr.Close()
End Sub
------------------------------------------------------------------------------
open dialog box, a microsoft textbox(in COM components) to display the .doc
file and a texbox to display the pathname of the file, it can open the .doc
file but the display is all messy and the characters and spaces wont appear
right.
is there another way to open a .doc file within the form in vb.net and make
it appear the same as the format when opening it in MS WORD?? (like the
paragraphs, pages, fonts, etc)
------------------------------------------------------------------------------
-------------------------------------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.
EventArgs) Handles Button1.Click
Dim openFileDialog1 As New OpenFileDialog()
Dim file_doc As String
Dim di As New DirectoryInfo("c:\")
openFileDialog1.Title = "Please Select a File"
openFileDialog1.InitialDirectory = "c:\"
openFileDialog1.Filter = "ms word files (*.doc)|*.doc"
openFileDialog1.ShowDialog()
file_doc = openFileDialog1.FileName.ToString()
TextBox1.Text = file_doc 'pathname
Dim fs As New FileStream(file_doc, FileMode.Open, FileAccess.Read)
Dim sr As New StreamReader(fs)
sr.BaseStream.Seek(0, SeekOrigin.Begin)
While sr.Peek() > -1
AxTextBox1.MultiLine = True
AxTextBox1.Text &= sr.ReadLine()
End While
sr.Close()
End Sub
------------------------------------------------------------------------------