reading a word doc line by line

S

sara

I have a .net applicationa and need to read a word
document line by line. I need to parse certain lines into
certain fields of the database. I Haven't a clue how to do
this.

Can anyone help please??
 
C

Cindy Meister -WordMVP-

Hi Sara,

Attempting to read a Word document line-by-line is not really
something you want to do. If for no other reason than that
the lines can break at different points depending on the
printer driver installed!

Are these lines actually paragraphs? (Do they end with a vbCR
character) Then use For Each on the paragraphs collection of
the document object.
I have a .net applicationa and need to read a word
document line by line. I need to parse certain lines into
certain fields of the database. I Haven't a clue how to do
this.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan
24 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :)
 
D

Dean

Here's some quick code for you to look at and modify to
parse as you see fit. This code assumes each line is
paragraph as Cindy points out below.

Sub ReadingFromWordLines()
Dim i As Integer
Dim LineIn As String, dataToReturn As String

For i = 1 To ActiveDocument.Paragraphs.Count
LineIn = ActiveDocument.Paragraphs(i)

If Left(LineIn, 7) = "ReadRec" Then
dataToReturn = Mid(LineIn, 15, 7)
End If
Next i

If Len(dataToReturn) > 0 Then
MsgBox dataToReturn
Else
MsgBox "No data to return"
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top