使用此代码:
Sub CreateNewField()
Dim x As TableField
Dim Field As String
Field = "TestCustomField"
'Check if the Custom Field is already created
If (CustomFieldExists(Field) = True) Then
MsgBox ("The Field Exists")
'If the Custom field doesn't exists
Else
MsgBox ("Doesn't exist")
CustomFieldRename FieldID:=pjTaskNumber1, NewName:=Field
'Adding to the table
Set x = ActiveProject.TaskTables(Application.ActiveProject.CurrentTable).TableFields.Add(pjTaskNumber1)
End If
'Calculate and adding graphical indicator to the Custom Field
CalculateCustomField (Field)
AddGraphicIndicator (Field)
End Sub
代码正确修改了自定义字段“数字 1”并将其添加到表中,但在我关闭 Project 并再次重新打开它之前,它不会像甘特图中的列一样出现。是否有另一种方法可以在甘特图中显示自定义字段而无需关闭并重新打开 Project 2007 文件?