Our forums are currently in maintenance mode and the ability to post is disabled. We will be back up and running as soon as possible. Thanks for your patience!



Read word document line by line using,or c#

By rejithram ·
I have a word file and I wish to extract certain information from it. For example, i wish to extract the filds called info of interest:
using or

News: Info of interest

Title: Info of interest

DAte: Info of interest>

Subject: info of interest

I want to be able to:

-Open doc file

-Read first line

- extract the .

-Go to next line & repeat process until end of file.

Can anyone help please????




Imports System.IO.File
Imports sqld
Public Class Form1

Private ob1 As sqld.sqld.sqldb
Public Sub New()

' This call is required by the Windows Form Designer.
ob1 = New sqld.sqld.sqldb()
' Add any initialization after the InitializeComponent() call.

End Sub
Private WordApp As New Word.ApplicationClass()

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
OpenFileDialog1.Filter = "Word Documents|*.doc"
txtFileName.Text = OpenFileDialog1.FileName
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim WordApp As New Word.ApplicationClass()

Dim file As Object = OpenFileDialog1.FileName
'Dim wdLineType1 As Word.WdLineType = Word.WdLineType.wdTextLine

Dim nullobj As Object = System.Reflection.Missing.Value

Dim doc As Word.Document = WordApp.Documents.Open(file, nullobj, nullobj, nullobj, nullobj, nullobj, _
nullobj, nullobj, nullobj, nullobj, nullobj, nullobj, _
nullobj, nullobj, nullobj)
'Dim st As System.Type
'st = wdLineType1.GetType
'Dim doc1 As Word.Document = WordApp.ActiveDocument

Label2.Text = doc.Range(0, 9).Text

' Label2.Text += " " + doc.'wdLineType1.GetValues(st).GetValue(1).ToString
'Dim m_Content As String = doc1.Content.Text
'Label2.Text = m_Content


'Dim data As IDataObject = Clipboard.GetDataObject()

''Do whatever with the text.
'Label2.Text = data.GetData(DataFormats.StringFormat)

'Close doc and shutdown Word application.
doc.Close(nullobj, nullobj, nullobj)
WordApp.Quit(nullobj, nullobj, nullobj)
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim temp As String = Label2.Text.ToString()
Dim ch As Char() = {":"}
Dim str1 As String() = Label2.Text.Split(ch)
For i As Integer = 0 To str1.GetUpperBound(0)

'Dim str22 As String = ob1.insertNData(str1(1), str1(3), str1(5), str1(7)).ToString()

i = i + 1
Catch ie As IndexOutOfRangeException
End Try
End Sub
End Class

please help

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Share your knowledge

Related Discussions

Related Forums