Share via


Task.GetField メソッド (Project)

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

構文

GetField( _FieldID_ )

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

パラメーター

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

戻り値

String

注釈

タスクのユーザー設定フィールドが見積もり期間の場合、取得される値には、見積もり額を表す文字も含まれます。

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

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

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

  2. 新しいユーザー設定フィールドが含まれるように、プロジェクトのサーバー プロファイルを使用して 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 のサポートおよびフィードバックを参照してください。