【发布时间】:2014-05-04 07:40:36
【问题描述】:
我需要帮助创建一个宏以在 powerpoint 2013 中查找文本。我在这里和网上找到了一些答案,但没有任何效果(可能是因为他们使用旧办公室 2010)我不是专家(老派程序员)我只需要在全屏时放置一个在演示文稿中工作的搜索框。我的演示文稿有近 1,600 页(是的,不要问它为什么或如何在 4 GB 内存、2.2 ghz 笔记本电脑上运行,但确实如此)我尝试了很多代码,但每个人都失败了。这里有什么帮助吗? (用于反欺凌项目)
类似的东西(在这里找到)
选项显式
子 HighlightKeywords() 将 sld 调暗为幻灯片 将 shp 变暗为形状 Dim txtRng As TextRange, rngFound As TextRange Dim i As Long, n As Long 暗淡目标列表
'~~> 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
结束子
【问题讨论】:
-
等等。 1600 页的演示文稿不是真正的演示文稿吗?是时候探索不同的工具了吗,例如 HTML、javascript 或构建自定义应用程序?
标签: search text macros powerpoint