Question

With this code:

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

The code correctly modifies the custom field "Number 1" and adds it to the table, but it doesn't appear like a Column in the Gantt chart until I close Project and reopen it again. Is there another way to show the custom field in the Gantt chart without closing and reopening Project 2007 file?

Was it helpful?

Solution

This is definitely an old post now, but it still might be useful to have an answer.

I had kind of the same issue, I wanted to add the existing field "Work" to the "Entry" Table. I managed to add it, but it was not showing in the table.

Now, to apply the changes, I simply open the table again by calling the TableApply method:

appProj.TableEditEx "Entry", True, , , , , "Work"
appProj.TableApply "Entry"

It works fine for me.

OTHER TIPS

This post is a little old, so maybe you have moved on, but have you calculated the project and made sure that Application.ScreenUpdating = True?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top