Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
45 lines (27 sloc) 1.65 KB
title ms.prod api_name ms.assetid ms.date localization_priority
TextRange2.Replace method (Office)
office
Office.TextRange2.Replace
e14f0ad0-3b9c-d9f5-a13d-d3bbdcae50e1
01/25/2019
Normal

TextRange2.Replace method (Office)

Finds specific text in a text range, replaces the found text with a specified string, and returns a TextRange2 object that represents the first occurrence of the found text. Returns Nothing if no match is found.

Syntax

expression.Replace (FindWhat, ReplaceWhat, After, MatchCase, WholeWords)

expression An expression that returns a TextRange2 object.

Parameters

Name Required/Optional Data type Description
FindWhat Required String The text to search for.
ReplaceWhat Required String The text you want to replace the found text with.
After Optional Long The 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.
MatchCase Optional MsoTriState Determines whether a distinction is made on the basis of case.
WholeWords Optional MsoTriState Determines whether only whole words are searched.

Return value

TextRange2

See also

[!includeSupport and feedback]

You can’t perform that action at this time.