Table of contents
Collapse the table of content
Expand the table of content

TextRange.Find Method (PowerPoint)

office 365 dev account|Last Updated: 6/12/2017
1 Contributor

Finds the specified text in a text range, and returns a TextRange object that represents the first text range where the text is found. Returns Nothing if no match is found.


expression. Find( FindWhat, After, MatchCase, WholeWords )

expression A variable that represents a TextRange object.


NameRequired/OptionalData TypeDescription
FindWhatRequiredStringThe text to search for.
AfterOptionalLongThe position of the character (in the specified text range) after which you want to search for the next occurrence of FindWhat. For example, if you want to search from the fifth character of the text range, specify 4 for After. If this argument is omitted, the first character of the text range is used as the starting point for the search.
MatchCaseOptionalMsoTriStatemsoTrue for the search to distinguish between uppercase and lowercase characters.
WholeWordsOptionalMsoTriStatemsoTrue for the search to find only whole words and not parts of larger words as well.

Return Value



This example finds every occurrence of "CompanyX" in the active presentation and formats it as bold.

For Each sld In Application.ActivePresentation.Slides 
    For Each shp In sld.Shapes 
        If shp.HasTextFrame Then 
            Set txtRng = shp.TextFrame.TextRange 
            Set foundText = txtRng.Find(FindWhat:="CompanyX") 
            Do While Not (foundText Is Nothing) 
                With foundText 
                    .Font.Bold = True 
                    Set foundText = _ 
                        txtRng.Find(FindWhat:="CompanyX", _ 
                        After:=.Start + .Length - 1) 
                End With 
        End If 

See also


TextRange Object

© 2018 Microsoft