I want to open a word document and display all the text in a windows forms.
Like the Ms Word Viewer. Only for read it, no modify.
I do not have problems opening and reading the document. The problem is
display de text. I do it of the following form:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles MyBase.Load
filename = "C:\1.doc"
Wrd.Documents.Open(filename, confirmConversions, rd, addToRecentFiles,
passwordDocument, passwordTemplate, revert, writePasswordDocument,
writePasswordTemplate, format, encoding, vis)
End Sub
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Dim range As Object
Dim str As New System.Text.StringBuilder
Dim drawfont As Font
Dim drawbrush As SolidBrush
Wrd.ActiveDocument.Range.SetRange(0, Wrd.ActiveDocument.Words.Count)
Wrd.ActiveDocument.Range.Start = 0
Wrd.ActiveDocument.Range.End = Wrd.ActiveDocument.Words.Count - 1
For Each Rng In Wrd.ActiveDocument.Words
' Create font and brush.
drawfont = New Font(Rng.Font.Name, Rng.Font.Size, FontStyle.Regular)
drawbrush = New SolidBrush(Color.Black)
Dim drawFormat As New StringFormat
drawFormat.FormatFlags = StringFormatFlags.DirectionVertical
' Draw string to screen.
str.Append(Rng.Text & " ")
Next
e.Graphics.DrawString(str.ToString, drawfont, drawbrush, x, y)
End Sub
'I don´t use any text editor because I won´t edit the text, only read.
Some suggestion?