0
votes

I want help to create a macro to find text in powerpoint 2013. I found some answers here and online but nothing worked ( probably because they use the old office 2010 ) I am not an expert ( old school programmer ) I just need to place a search box that work inside a presentation while in full screen. my presentation have almost 1,600 pages ( yeah, don't ask why or how it runs in a 4 gb ram, 2.2 ghz laptop but it does ) I tried many codes but everyone failed. any help around here? ( is for a anti bully project )

something like this ( found here )

Option Explicit

Sub HighlightKeywords() Dim sld As Slide Dim shp As Shape Dim txtRng As TextRange, rngFound As TextRange Dim i As Long, n As Long Dim TargetList

'~~>  Array of terms to search for
TargetList = Array("keyword", "second", "third", "etc")

'~~> Loop through each slide
For Each sld In Application.ActivePresentation.Slides
    '~~> Loop through each shape
    For Each shp In sld.Shapes
        '~~> Check if it has text
        If shp.HasTextFrame Then
            Set txtRng = shp.TextFrame.TextRange

            For i = 0 To UBound(TargetList)
                '~~> Find the text
                Set rngFound = txtRng.Find(TargetList(i))

                '~~~> If found
                Do While Not rngFound Is Nothing
                    '~~> Set the marker so that the next find starts from here
                    n = rngFound.Start + 1
                    '~~> Chnage attributes
                    With rngFound.Font
                        .Bold = msoTrue
                        .Underline = msoTrue
                        .Italic = msoTrue
                        '~~> Find Next instance
                        Set rngFound = txtRng.Find(TargetList(i), n)
                    End With
                Loop
            Next
        End If
    Next
Next

End Sub

1
Wait. A presentation with 1600 pages is not really a presentation is it? Is it time to explore different tools, like HTML, javascript or building a custom app?RowanC

1 Answers

0
votes

Any shape on a slide can trigger a macro. Suppose you have a HelloWorld sub in the PPTM file. You can add a shape to any slide, give it an Action Setting of Run Macro: HelloWorld.

So instead of a simple HelloWorld macro, you could write code that displays a user form, the user form could collect the text you want to search for. From there, what happens next depends on what you want to search for and what you want to do with the results. You haven't mentioned that.