0
votes

I Would like to select a sentence (complete line) if a certain word occurs in the sentence.

For example:

Sentence : Hello My name is vinod. I am from Hyderabad.

Program: If the word hello is found in the sentence. Print complete sentence "Hello My name is vinod. I am from Hyderabad."

I found a program which uses Extends in word VBA. I would like to use the same for Power Point. here is the link for the code for reference

Extract sentences containing a specific word to excel file

1

1 Answers

1
votes

You can use the Sentences attribute of the TextRange

Dim sld As Slide, shp As Shape, sentence As TextRange
For Each sld In ActivePresentation.Slides
    For Each shp In sld.Shapes
        If shp.HasTextFrame Then
            For Each sentence In shp.TextFrame.TextRange.Sentences
                If Not sentence.Find("hello", , , msoTrue) Is Nothing Then
                    Debug.Print sentence ' <-- do the action you want on the sentence
                End If
            Next
        End If
    Next
Next