Question
Thread display: Collapse - |
All Answers
Share your knowledge
Start or search
Create a new discussion
If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.
Read word document line by line using vb.net,or c#
using vb.net or c#.net
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????
Thanks
REjith
code
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.
InitializeComponent()
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
OpenFileDialog1.ShowDialog()
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)
doc.Activate()
'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
'doc.ActiveWindow.Selection.WholeStory()
'doc.ActiveWindow.Selection.Copy()
'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)
Try
For i As Integer = 0 To str1.GetUpperBound(0)
'MessageBox.Show(str1(3).ToString())
'Dim str22 As String = ob1.insertNData(str1(1), str1(3), str1(5), str1(7)).ToString()
i = i + 1
Next
Catch ie As IndexOutOfRangeException
ie.ToString()
End Try
End Sub
End Class
please help