根据Powerpoint中的关键字选择幻灯片
我正在尝试创建一个宏,该宏将选择标题中包含关键字的任何幻灯片,但没有任何结果。该 ppt 包括不同的首页、免责声明和内容幻灯片,其想法是向每张幻灯片的标题添加关键字,并使用宏来选择所选幻灯片并将其导出为 PDF。
我已经使导出部分正常工作,但需要手动输入幻灯片编号。
我从类似的问题中获得了下面的代码,但无法重写它以选择幻灯片而不是将答案呈现为 MsgBox。有人可以帮忙吗?
Sub FindText()
Dim sld As Slide, shp As Shape, list As String, myPhrase As String
myPhrase = InputBox("enter a phrase", "Search for what?")
For Each sld In Application.ActivePresentation.Slides
For Each shp In sld.Shapes
If shp.HasTextFrame Then
If Left(shp.Name, 5) = "Title" Then
If Not shp.TextFrame.TextRange.Find(FindWhat:=myPhrase) Is Nothing Then
If list = "" Then list = sld.Name Else list = list & ", " & sld.Name
End If
End If
End If
Next shp
Next sld
MsgBox list
End Sub
I'm trying to create a macro that will select any slide that contains a keyword in the title, but not getting anywhere. The ppt includes different frontpages, disclaimers and content slides and the idea is to add keywords to the titles of each slide and get the macro to select and export the selected slides to PDF.
I've got the export part working, but have the enter the slide numbers manually.
I got the code below from a similar question, but can't rewrite it to select the slides instead of presenting the answers as a MsgBox. Can somebody help, please?
Sub FindText()
Dim sld As Slide, shp As Shape, list As String, myPhrase As String
myPhrase = InputBox("enter a phrase", "Search for what?")
For Each sld In Application.ActivePresentation.Slides
For Each shp In sld.Shapes
If shp.HasTextFrame Then
If Left(shp.Name, 5) = "Title" Then
If Not shp.TextFrame.TextRange.Find(FindWhat:=myPhrase) Is Nothing Then
If list = "" Then list = sld.Name Else list = list & ", " & sld.Name
End If
End If
End If
Next shp
Next sld
MsgBox list
End Sub
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的完整代码,使用史蒂夫的解决方案,如果有人试图解决同样的问题:
My full code, using Steve's solution, if anyone is trying to solve the same problem:
默认情况下,当您另存为 PDF 时,PDF 不会包含任何隐藏的幻灯片,因此您只需先隐藏所有幻灯片,然后取消隐藏要包含在 PDF 中的任何幻灯片即可。虽然我没有在这里执行此操作,但在保存为 PDF 后,您将需要再次取消隐藏所有幻灯片。
By default, when you save as PDF, the PDF won't include any slides that are hidden, so you can simply hide all the slides first, then UNHIDE any that you want to include in the PDF. While I haven't done this here, you'll want to UNHIDE all the slides again after saving to PDF.