如果句子中出现某个单词,我想选择一个句子(完整的一行)。
例如:
句子:你好,我叫维诺德。我来自海得拉巴。
程序:如果在句子中找到单词hello。打印完整的句子“你好,我的名字是维诺德。我来自海得拉巴。”
我在word VBA中找到了一个使用扩展的程序。我想在Power Point中使用同样的方法。以下是代码的链接以供参考
Extract sentences containing a specific word to excel file
发布于 2017-01-28 19:37:29
您可以使用TextRange的Sentences属性
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
Nexthttps://stackoverflow.com/questions/41908884
复制相似问题