Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to read a line from Ms Word


I want to read Ms Word file line by line. Is there any way other than
Paragraph & Word to select range. Can i select range in MS word line by
line.

for eg. inplace of following code can i use "Line" in place of
"paragraph"????
'**********
with MSWD

'Set trange = .Range(Start:=.Paragraphs(3).Range.Start,
End:=.Paragraphs(3).Range.End)

end with
'**************
if not tell me how Ms word recognises When Paragraph has started &
when ended????

I am really willing to know

thanks in advance

With Regards
Excel Power


--
ExcelPower
------------------------------------------------------------------------
ExcelPower's Profile: http://www.excelforum.com/member.php...o&userid=30964
View this thread: http://www.excelforum.com/showthread...hreadid=514832

  #2   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 399
Default How to read a line from Ms Word

Word does not contain a "Line" object. The Selection object of the Word
application contains a "measurement" Unit of wdLine, but it's not available
to the Range object. The following code opens a document, and then moves
line by line using the Selection object. The text of each line is set into
a string that you can manipulate; here, it's printed to the Immediate
window. Note that you will have to set up strDoc - the file path and name
of your Word doc - for yourself.

HTH
Ed

Sub TestReadWord()

Dim appWD As Word.Application
Dim docWD As Word.Document
Dim rngWD As Word.Range
Dim strDoc As String
Dim strLine As String
Dim bolEOF As Boolean

bolEOF = False

' Set strDoc here to include the full
' file path and file name

On Error Resume Next
Set appWD = GetObject(, "Word.Application")
If Err.Number < 0 Then
Set appWD = CreateObject("Word.Application")
End If
Err.Clear
On Error GoTo 0

Set docWD = appWD.Documents.Open(strDoc)
appWD.Visible = True

docWD.Characters(1).Select

Do
appWD.Selection.MoveEnd Unit:=wdLine, Count:=1
strLine = appWD.Selection.Text
Debug.Print strLine
appWD.Selection.Collapse wdCollapseEnd

If appWD.Selection.Bookmarks.Exists("\EndOfDoc") Then bolEOF = True
Loop Until bolEOF = True


docWD.Close wdDoNotSaveChanges
Set docWD = Nothing
appWD.Quit
Set appWD = Nothing

End Sub
"ExcelPower" wrote
in message ...

I want to read Ms Word file line by line. Is there any way other than
Paragraph & Word to select range. Can i select range in MS word line by
line.

for eg. inplace of following code can i use "Line" in place of
"paragraph"????
'**********
with MSWD

'Set trange = .Range(Start:=.Paragraphs(3).Range.Start,
End:=.Paragraphs(3).Range.End)

end with
'**************
if not tell me how Ms word recognises When Paragraph has started &
when ended????

I am really willing to know

thanks in advance

With Regards
Excel Power


--
ExcelPower
------------------------------------------------------------------------
ExcelPower's Profile:

http://www.excelforum.com/member.php...o&userid=30964
View this thread: http://www.excelforum.com/showthread...hreadid=514832



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to read a line from Ms Word


thanks Ed this works great
one more thing your style of communication is clear & clean- keep
helping

bye

thanks again

with regards

Excel Power


--
ExcelPower
------------------------------------------------------------------------
ExcelPower's Profile: http://www.excelforum.com/member.php...o&userid=30964
View this thread: http://www.excelforum.com/showthread...hreadid=514832

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
read multiple line JaiJai[_5_] Excel Programming 10 November 14th 05 02:01 PM
How do I read values from a line chart? Lynn Charts and Charting in Excel 3 October 9th 05 09:11 PM
Textbox-read text line by line antonio Excel Programming 0 October 26th 04 05:42 PM
Read previous line of textfile Adrian[_4_] Excel Programming 2 May 1st 04 04:20 AM
read last line of a file Mike[_49_] Excel Programming 4 November 25th 03 10:41 PM


All times are GMT +1. The time now is 03:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"