PowerPoint tips, hints and tutorials that will change your presentations for ever!



Custom Shows
vba code
Games for teachers
Flash Cards
Multiple Instances
PowerPoint 2007
Mail Merge
Random events
Set spellcheck language

Home buttonTutorial buttonContact buttonProducts button

A Search Box (vba)

This shows you how to make a simple search box which will jump you to the first slide that includes the entered text.

You will need to insert a TextBox from the Control Toolbar. If you don't know how to do this see here.

Now Right click on the new toolbox and choose VIEW CODE:

You should see two lines of code that look like this:

Private Sub TextBox1_Change()

End Sub

Ignore this code and instead use the Drop Arrow on the right to choose "Key Down"


key down

You should now see code similar to this:

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)

End Sub

Between these two lines paste this code:

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

Now run the show and type the text to find in the box followed bty ENTER. If all is well it will jump to the correct slide.

If you have 2007 on save as a .pptm file.



Back to the Index Page


Articles on your favourite sport

Free Microsoft PowerPoint Advice, help and tutorials, Template Links
This website is sponsored by Technology Trish Ltd
© Technology Trish 2007
Registered in England and Wales No.5780175
PowerPoint® is a registered trademark of the Microsoft Corporation