Last active
September 27, 2016 12:03
-
-
Save tdalon/a4d01aed9c1766ed6986c2332a0d8b71 to your computer and use it in GitHub Desktop.
PowerPoint VBA TextBox KeyDown Callback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) | |
' https://tdalon.blogspot.com/2016/09/powerpoint-quick-search-tagged-slides.html | |
' References: http://stackoverflow.com/questions/26587114/powerpoint-search-box-vba | |
' Hidden Search TextBox | |
Dim osld As Slide | |
Dim oshp As Shape | |
Dim sTextToFind As String | |
If KeyCode <> 13 Then 'ENTER PRESSED | |
Exit Sub | |
End If | |
sTextToFind = Me.TextBox1.Text | |
If Left(sTextToFind, 1) = "#" Then ' Only look for tagged shapes if search for tag | |
For Each osld In ActivePresentation.Slides | |
For Each oshp In osld.Shapes | |
If (oshp.Tags("HideMe") = "YES") And oshp.HasTextFrame Then | |
If oshp.TextFrame.HasText Then | |
If InStr(UCase(oshp.TextFrame.TextRange), UCase(sTextToFind)) > 0 Then | |
SlideShowWindows(1).View.GotoSlide (osld.SlideIndex) | |
Exit Sub | |
End If | |
End If | |
End If | |
Next oshp | |
Next osld | |
Else | |
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(sTextToFind)) > 0 Then | |
SlideShowWindows(1).View.GotoSlide (osld.SlideIndex) | |
Exit Sub | |
End If | |
End If | |
End If | |
Next oshp | |
Next osld | |
End If | |
MsgBox "Not found" | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment