我想在PowerPoint中編碼一些vba來搜索幻燈片中的單詞,然後轉到該幻燈片並以某種方式格式化該單詞以使其突出顯示。到目前爲止,我有添加一個ActiveX文本框,用下面的代碼:powerpoint搜索框vba
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
這工作正常上字查找幻燈片,但不格式化字。有任何想法嗎??
我鼓勵你將代碼格式化爲更具可讀性,現在真的很難遵循現在的方式 – tkanzakic 2014-10-27 12:07:40
感謝你爲Matt – edparker109 2014-10-27 13:45:45