Select line of text in Word documents

How can I "Select a line of text in Word documents" to futher manipulate it I figured how to do individual Words, but I'd like to select a line ot text containing a certain word.


Answer this question

Select line of text in Word documents

  • Soroush Atarod

    Not too sure how to select a line of text, but this will select the sentence containing the word:

    Sub SelectSentence()
    Dim oDoc As Word.Document

    Set oDoc = Documents.Open("C:\documents and settings\mydocument")
    With Selection.Find
    .Text = InputBox("Enter word to find")
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = True
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute
    If .Found Then
    Selection.Extend
    Selection.Extend
    Selection.Extend
    MsgBox Selection
    End If

    oDoc.Close
    Set oDoc = Nothing
    End With
    End Sub

  • Select line of text in Word documents