TextRange2.Replace Method
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.
Namespace: Microsoft.Office.Core
Assembly: office (in office.dll)
Syntax
'Declaration
Function Replace ( _
FindWhat As String, _
ReplaceWhat As String, _
After As Integer, _
MatchCase As MsoTriState, _
WholeWords As MsoTriState _
) As TextRange2
'Usage
Dim instance As TextRange2
Dim FindWhat As String
Dim ReplaceWhat As String
Dim After As Integer
Dim MatchCase As MsoTriState
Dim WholeWords As MsoTriState
Dim returnValue As TextRange2
returnValue = instance.Replace(FindWhat, _
ReplaceWhat, After, MatchCase, WholeWords)
TextRange2 Replace(
string FindWhat,
string ReplaceWhat,
int After,
MsoTriState MatchCase,
MsoTriState WholeWords
)
Parameters
FindWhat
Type: System.StringThe text to search for.
ReplaceWhat
Type: System.StringThe text you want to replace the found text with.
After
Type: System.Int32The 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
Type: Microsoft.Office.Core.MsoTriStateDetermines whether a distinction is made on the basis of case.
WholeWords
Type: Microsoft.Office.Core.MsoTriStateDetermines whether only whole words are searched.
Return Value
Type: Microsoft.Office.Core.TextRange2
TextRange2