Vba Ms Project 2007添加自定义字段甘特图(不显示)

Vba Ms Project 2007添加自定义字段甘特图(不显示),vba,ms-project,Vba,Ms Project,使用此代码: 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 exis

使用此代码:

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 2007文件?

这篇文章有点旧,因此您可能已经继续,但您是否计算了项目并确保Application.ScreenUpdate=True?

这肯定是一篇旧文章,但有一个答案可能仍然有用

我也有类似的问题,我想将现有字段“Work”添加到“Entry”表中。我设法添加了它,但它没有显示在表中

现在,要应用这些更改,我只需通过调用TableApply方法再次打开表:

appProj.TableEditEx“条目”,True,,,,“工作”
appProj.table应用“条目”


这对我来说很好。

谢谢你的回答,我不再使用VBA了,不幸的是,我无法访问该文件来检查你的答案,但我希望这可以帮助将来有同样问题的任何人。再次感谢!:)你好,欧莲,是的,这是非常古老的,但我感谢有人回答这个疑问。它可能对其他用户有用!谢谢你的帮助。