Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a Get Line Function in Word VBA? 1

Status
Not open for further replies.

vbLew

Programmer
Feb 28, 2005
22
US
I'm looking for a method in Word VBA to read a Sentence from Word and then store it into a string. But I do not want to convert the Word Doc to a text file.




 

Hi,

Take a look at this code
Code:
    Dim para As Paragraph, s
    For Each para In Paragraphs
        For Each s In para.Range.Sentences
            MsgBox s.Text
        Next
    Next

Skip,

[glasses] [red]Be advised:[/red]We know Newton's 3 Laws. But did you hear about the [red]FOURTH???[/red]
Only ONE fig per cookie![tongue]
 
The code worked out well. I only had to change:

For each para in Paragraphs

to

For each para in ActiveDocuments.Paragraphs


By the way, what is s in the code? Is it a sentence or paragraph??


 
I'd say it's a range object

[tt] Dim para As Paragraph
dim s as range

For Each para In Paragraphs
For Each s In para.Range.Sentences
MsgBox s.Text
Next s
Next para[/tt]

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top