我需要帮助来创建宏以在Powerpoint 2013中查找文本。我在这里和在线上找到了一些答案,但是没有用(可能是因为他们使用的是旧版Office 2010)。我不是专家(旧派程序员),我只需要在全屏模式下放置一个可在演示文稿中使用的搜索框。我的演示文稿几乎有1600页(是的,不要问为什么或为什么要在4 GB内存,2.2 GHz笔记本电脑中运行,但确实如此)我尝试了很多代码,但每个人都失败了。这里有什么帮助吗? (用于反欺凌项目)
类似这样的东西(在这里找到)
选项显式
Sub HighlightKeywords()暗淡的sld作为幻灯片形状变薄昏暗的txtRng为TextRange,rngFound为TextRange尽可能长昏暗的TargetList
'~~> Array of terms to search for
TargetList = Array("keyword", "second", "third", "etc")
'~~> Loop through each slide
For Each sld In Application.ActivePresentation.Slides
'~~> Loop through each shape
For Each shp In sld.Shapes
'~~> Check if it has text
If shp.HasTextFrame Then
Set txtRng = shp.TextFrame.TextRange
For i = 0 To UBound(TargetList)
'~~> Find the text
Set rngFound = txtRng.Find(TargetList(i))
'~~~> If found
Do While Not rngFound Is Nothing
'~~> Set the marker so that the next find starts from here
n = rngFound.Start + 1
'~~> Chnage attributes
With rngFound.Font
.Bold = msoTrue
.Underline = msoTrue
.Italic = msoTrue
'~~> Find Next instance
Set rngFound = txtRng.Find(TargetList(i), n)
End With
Loop
Next
End If
Next
Next
结束子
幻灯片上的任何形状都可以触发宏。假设您在PPTM文件中有一个HelloWorld子项。您可以向任何幻灯片添加形状,并为其设置运行宏的动作设置:HelloWorld。
因此,您可以编写显示用户表单的代码,而不是简单的HelloWorld宏,该用户表单可以收集要搜索的文本。从那里开始,接下来会发生什么取决于您要搜索的内容以及要对结果执行的操作。您没有提到过。
我需要帮助。请指教。“您可以编写显示用户表单的代码,该用户表单可以收集您要搜索的文本。