Compartir a través de


Application.Replace Method (Project)

Searches for an unfiltered value and replaces it with the specified value. Returns True if any replacements are made.

Syntax

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

expression A variable that represents an Application object.

Parameters

Name

Required/Optional

Data Type

Description

Field

Optional

String

The name of the field to search.

Test

Optional

String

The type of comparison made between Field and Value. Can be one of the following comparison strings:

Comparison string Description
"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.

Value

Optional

Variant

The value to compare with the value of the field specified in Field.

Replacement

Optional

Variant

Use "" (an empty string) to clear Field where it meets the test specified by Test and Value.

ReplaceAll

Optional

Variant

True if all occurrences of Value are replaced. False if only the first occurrence is replaced. The default value is False.

Next

Optional

Variant

True 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.

MatchCase

Optional

Variant

True if the search is case-sensitive. The default value is False.

FieldID

Optional

Variant

The field identification number can be one of the PjField constants. FieldID takes precedence over any Field value.

TestID

Optional

Variant

The test identification number can be one of the PjComparison constants. TestID takes precedence over any Test value.

Return Value

Boolean

Remarks

Using the Replace method with no arguments, or without specifying Field, Test, and Value, displays the Replace dialog box that has options set for the previous state.

To replace a value in all available fields, use the ReplaceEx method.

Example

Either statement in the following example lowers the priority of all tasks that are equal to or over 800 to priority 600.

Sub LowerPriority() 
 Replace Field:="Priority", Test:="is greater than or equal to", Value:="800", Replacement:="600", _ 
 ReplaceAll:=True 
 Replace Field:="xx", Test:="xx", FieldID:=pjTaskPriority, TestID:=pjCompareGreaterThanOrEqual, _ 
 Value:="800", Replacement:="600" 
End Sub