共用方式為


應用。替換方法 (專案)

搜尋未篩選的值並取代指定的值。

語法

表情替換欄位 (、測試替換、全部替換NextMatchCaseFieldIDTestID)

expression 代表 Application 物件的變數。

參數

名稱 必要/選用 資料類型 描述
Field 選用 String 要搜尋的欄位名稱。
Test 選用 String 欄位 之間所進行的比較類型。 可以作為 比較字串之一。
選用 Variant 要比較的值 與欄位中指定的欄位值比較。
Replacement 選用 Variant 使用空字串 (「」,) 清除與 TestValue 指定的測試相符的欄位
全部替換 選用 Variant True 是表示 如果 Value的所有項目所取代。 False 只有第一個找到已被取代。 預設值為 False
Next 選用 Variant True 是表示 如果專案往上搜尋下一個出現的比對搜尋準則。 為 false ,則專案會搜尋以為下一個出現。 預設值為 True
MatchCase 選用 Variant True 是表示 如果搜尋不區分大小寫。 預設值為 False
FieldID 選用 Variant 場識別數可以是 PjField 常數之一。 FieldID 的優先順序高於任何 Field 值。
TestID 選用 Variant 測試識別號碼可以是 PjComparison 常數之一。 TestID 優先於任何 Test 值。

比較字串

比較字串 描述
"equals" Field 的值等於 Value
"does not equal" Field 的值不等於 Value
"is greater than" Field 的值大於 Value
"is greater than or equal to" Field 的值大於或等於 Value
"is less than" Field 的值小於 Value
"is less than or equal to" Field 的值小於或等於 Value
"is within" Field 的值在 Value 之間。
"is not within" Field 的值不在 Value 之間。
"contains" 欄位 包含
"does not contain" 欄位 不包含 Value
"contains exactly" 欄位 恰好包含

傳回值

布林值

True如果進行任何取代;否則 False

註解

使用 替換 方法時,不使用參數,或未指定 欄位測試,會顯示替 對話框,並設定前一個狀態的選項。

若要取代所有可用欄位中的某個值,請使用 ReplaceEx 方法。

範例

下列範例中的這兩個陳述式都會將優先順序等於或超過 800 的所有任務降低為 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

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應