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

Application.ReplaceEx Method (Project)

office 365 dev account|Last Updated: 10/19/2017
2 Contributors

Searches for an unfiltered value in a specified field, or in all available fields, and replaces it with the specified value.


expression. ReplaceEx (Field, Test, Value, Replacement, ReplaceAll, Next, MatchCase, FieldID, TestID, SearchAllFields)

expression An expression that returns an Application object.


NameRequired/OptionalData TypeDescription
FieldOptionalStringThe name of the field to search.
TestOptionalStringThe type of comparison made between Field and Value. Can be one of the comparison strings.
ValueOptionalVariantThe value to compare with the value of the field specified in Field.
ReplacementOptionalVariantUse "" (an empty string) to clear Field where it meets the test specified by Test and Value.
ReplaceAllOptionalVariantTrue if all occurrences of Value are replaced. False if only the first occurrence is replaced. The default value is False.
NextOptionalVariantTrue if Project searches down for the next occurrence of matching search criteria. False if Project searches up for the next occurrence. The default value is True.
MatchCaseOptionalVariantTrue if the search is case-sensitive. The default value is False.
FieldIDOptionalVariantThe field identification number can be one of the PjField constants. FieldID takes precedence over any Field value.
TestIDOptionalVariantThe test identification number can be one of the PjComparison constants. TestID takes precedence over any Test value.
SearchAllFieldsOptionalVariantIf True, replace the specified value in all available fields. The default value is False. SearchAllFields takes precedence over Field and FieldID.

Comparison strings

Comparison stringDescription
"equals"The value of Field equals Value.
"does not equal"The value of Field does not equal Value.
"is greater than"The value of Field is greater than Value.
"is greater than or equal to"The value of Field is greater than or equal to Value.
"is less than"The value of Field is less than Value.
"is less than or equal to"The value of Field is less than or equal to Value.
"is within"The value of Field is within Value.
"is not within"The value of Field is not within Value.
"contains"Field contains Value.
"does not contain"Field does not contain Value.
"contains exactly"Field contains exactly Value.

Return value


True if any replacements are made; otherwise, False.


Using the ReplaceEx method with no arguments, or without specifying Field, Test, and Value, displays the Replace dialog box that has options set for the previous state. If you set SearchAllFields to True, programmatic use still requires values for the Field, Test, and Value parameters.


Either line in the following example replaces "Bad" with "Good", within the set of all available fields.

Sub Bad2Good() 
    ReplaceEx Field:="Name", Test:="contains", Value:="Bad", Replacement:="Good", _ 
        ReplaceAll:=True, SearchAllFields:=True 
    ReplaceEx Field:="xx", Test:="xx", TestID:=pjCompareContains, Value:="Bad", Replacement:="Good", _ 
        ReplaceAll:=True, SearchAllFields:=True 
End Sub
© 2018 Microsoft