Find Text in slideshow

  • Thread starter Thread starter Haggistech
  • Start date Start date
H

Haggistech

Hi Guys

I have a slide show with 100 slides

I have a text area on the front page and a button called search

I am trying to find a macro that will allow me to type into the text box and
click search and have it jump to the page it finds that word on

any help would be greatly appreciated
 
Hi Guys

I have a slide show with 100 slides

I have a text area on the front page and a button called search

I am trying to find a macro that will allow me to type into the text box and
click search and have it jump to the page it finds that word on

any help would be greatly appreciated

Something along these lines should work for you (watch out for
newsgroup-induced line breaks). Also note that this is using a MsgBox, but
you should be able to translate that into getting the text from your text
box.

Sub SearchForString()
Dim SearchString As String
Dim oSld As Slide
Dim oShp As Shape

SearchString = InputBox("Search for:")
For Each oSld In ActivePresentation.Slides
For Each oShp In oSld.Shapes
If oShp.HasTextFrame Then
If oShp.TextFrame.TextRange.Find(SearchString) Is Nothing =
False Then
ActivePresentation.SlideShowWindow.View.GotoSlide
oSld.SlideIndex
GoTo Done
End If
End If
Next oShp
Next oSld
Done:
End Sub


--
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
 
David Marcovitz said:
Something along these lines should work for you (watch out for
newsgroup-induced line breaks). Also note that this is using a MsgBox, but
you should be able to translate that into getting the text from your text
box.

Sub SearchForString()
Dim SearchString As String
Dim oSld As Slide
Dim oShp As Shape

SearchString = InputBox("Search for:")
For Each oSld In ActivePresentation.Slides
For Each oShp In oSld.Shapes
If oShp.HasTextFrame Then
If oShp.TextFrame.TextRange.Find(SearchString) Is Nothing =
False Then
ActivePresentation.SlideShowWindow.View.GotoSlide
oSld.SlideIndex
GoTo Done
End If
End If
Next oShp
Next oSld
Done:
End Sub


--
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland


.
Thats great it works

is it possible to use the form to show a find next so you can go to next
found item
 
Thats great it works

is it possible to use the form to show a find next so you can go to next
found item

Great, I'm glad it works for you. Adding a Find Next is certainly possible.
I don't have time to whip it together for you, but the simplest thing is
probably to adjust the procedure above in one of a couple of ways:

(1) You could change the loop through the slides from a For Each loop to a
loop that goes from the next slide to the last slide. Something like
(warning: this is air code):

For i = ActivePresentation.SlideShowWindow.View.Slide.SlideIndex To _
ActivePresentation.Slides.Count

so it only loops from the next slide to the last.

(2) You could add an If statement around the GoToSlide and Go To Done
statements to ask if the SlideIndex is greater than the current slide's
SlideIndex. Something like:

If oSld.SlideIndex > _
ActivePresentation.SlideShowWindow.View.Slide.SlideIndex Then

You also might want to have right before Done: a

MsgBox "Text not found"

statement to let people know the text was not found.

--David

--
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
 
Back
Top