Share via


Task.SetField メソッド (Project)

指定した、タスクのユーザー設定フィールドの値を設定します。

構文

SetField( _FieldID_, _Value_ )

Task オブジェクトを表す変数。

パラメーター

名前 必須 / オプション データ型 説明
FieldID 必須 長整数型 (Long) ローカルのユーザー設定フィールドは、タスク ユーザー設定フィールドの PjField 定数のいずれか。 エンタープライズ ユーザー設定フィールドの場合、 FieldIDを取得するのに FieldNameToFieldConstant メソッドを使用します。
Value 必須 String フィールドの値です。

注釈

ProjectSummaryTask プロパティを通じて、プロジェクトのユーザー設定フィールドにアクセスできます。

The following example uses the SetField method and the GetField method together with the FieldNameToFieldConstant and FieldConstantToFieldName methods.

  1. To use the example, use Project Web App to create an enterprise project text custom field named TestEntProjText.

  2. 新しいユーザー設定フィールドが含まれるように Project Server のプロファイルでは、Project Professional を再起動します。

  3. Create a project with some value for the TestEntProjText field, by using the Project Information dialog box.

  4. TestEnterpriseProjectCF マクロは、190873618、projectField 番号を検索する FieldNameToFieldConstant メソッドを使用します。

  5. マクロは、 GetField メソッドを使用して、メッセージ ボックスで、番号とテキストの値を示しています。

  6. マクロは、 FieldConstantToFieldName メソッドを使用してフィールド名を取得、 SetField メソッドを使用して新しい値を設定し、別のメッセージ ボックスで、フィールド名と新しい値を示します。

Sub TestEnterpriseProjectCF() 
    Dim projectField As Long 
    Dim projectFieldName As String 
    Dim message As String 
 
    projectField = FieldNameToFieldConstant("TestEntProjText", pjProject) 
 
    ' Show the enterprise project field number and old value. 
    message = "Enterprise project field number: " & projectField & vbCrLf 
    MsgBox message & ActiveProject.ProjectSummaryTask.GetField(projectField) 
 
    ActiveProject.ProjectSummaryTask.SetField FieldID:=projectField, Value:="This is a new value." 
 
    ' For a demonstration, get the field name from the field number, and verify the new value. 
    projectFieldName = FieldConstantToFieldName(projectField) 
    message = "New value for field: " & projectFieldName & vbCrLf 
    MsgBox message & ActiveProject.ProjectSummaryTask.GetField(projectField) 
End Sub

サポートとフィードバック

Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。