【发布时间】:2014-12-22 14:31:29
【问题描述】:
我正在尝试在 powerpoint 中编写一些 vba 代码以在幻灯片中搜索一个单词,然后转到该幻灯片并以某种方式格式化该单词以使其突出。到目前为止,我已经添加了一个 activex 文本框并使用了以下代码:
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger,ByVal Shift As Integer)
Dim osld As Slide
Dim oshp As Shape
Dim b_found As Boolean
If KeyCode = 13 Then 'ENTER PRESSED
If Me.TextBox1.Text <> "" Then
For Each osld In ActivePresentation.Slides
For Each oshp In osld.Shapes
If oshp.HasTextFrame Then
If oshp.TextFrame.HasText Then
If InStr(UCase(oshp.TextFrame.TextRange), UCase(Me.TextBox1.Text))>0 Then
SlideShowWindows(1).View.GotoSlide (osld.SlideIndex)
Me.TextBox1.Text = ""
b_found = True
Exit For
End If
End If
End If
Next oshp
If b_found = True Then Exit For
Next osld
End If
If b_found = False Then MsgBox "Not found"
End If
End Sub
这适用于查找带有单词但不格式化单词的幻灯片。有什么想法吗??
【问题讨论】:
-
我鼓励您将代码格式化为更具可读性,现在真的很难遵循它的方式
-
感谢马特的支持
标签: vba powerpoint