Application.TableEdit method (Project)

Creates, edits, or copies a table.

Syntax

expression. TableEdit( _Name_, _TaskTable_, _Create_, _OverwriteExisting_, _NewName_, _FieldName_, _NewFieldName_, _Title_, _Width_, _Align_, _ShowInMenu_, _LockFirstColumn_, _DateFormat_, _RowHeight_, _ColumnPosition_, _AlignTitle_, _HeaderAutoRowHeightAdjustment_, _HeaderTextWrap_ )

expression A variable that represents an Application object.

Parameters

Name Required/Optional Data type Description
Name Required String The name of a table to edit, create, or copy.
TaskTable Required Boolean True if the active table contains information about tasks or resources; otherwise, False.
Create Optional Boolean True if Project creates a table, otherwise, False. If NewName is not defined, the new table is given the name specified with Name. Otherwise, the new table is a copy of the table specified with Name and is given the name specified with NewName. The default value is False.
OverwriteExisting Optional Boolean True if an existing table is overwritten with the new table. The default value is False.
NewName Optional String The new name for the existing table (Create is False) or new table (Create is True). If NewName is not defined and Create is False, the table specified with Name retains its current name. The default value is an empty string ("").
FieldName Optional String The name of a field to change.
NewFieldName Optional String The name of a new field. The field specified with NewFieldName replaces the field specified with FieldName.
Title Optional String The title for the field specified with FieldName.
Width Optional Integer A number that specifies the width of the field specified with FieldName. The default value is 10 for new fields.
Align Optional Integer Specifies how to align the text in the field specified with FieldName. Can be one of the following PjAlignment constants: pjLeft, pjCenter, or pjRight. The default value is pjRight.
ShowInMenu Optional Boolean True if the table name appears in the Tables drop-down menu; otherwise, False. (The Tables drop-down menu is on the View tab of the Ribbon.) The default value is False.
LockFirstColumn Optional Boolean True if Project locks or prevents changes to the first column of the table; otherwise, False. The default value is False.
DateFormat Optional Integer A constant that specifies the format for the date fields in the table. Can be one of the PjDateFormat constants. The default value is pjDateDefault.
RowHeight Optional Integer The height of the rows in the table. The default value is 1.
ColumnPosition Optional Long The number of the column to edit. (Columns are numbered from left to right, starting with 0.) If a value for NewFieldName is specified, a new column is inserted in the table. If ColumnPosition is set to 0, the new field is inserted in the first column (LockFirstColumn is False) or the second column (LockFirstColumn is True) of the table. Set ColumnPosition to -1 to specify the last column of the table. The default value is -1.
AlignTitle Optional Long A constant that specifies the alignment of the column title. Can be one of the following PjAlignment constants: pjLeft, pjCenter, or pjRight. The default value is pjCenter.
HeaderAutoRowHeightAdjustment Optional Boolean True if Project automatically adjusts the row height of the table; otherwise, False. The default value is True.
HeaderTextWrap Optional Boolean True if Project wraps text in the header of the table; otherwise, False. The default value is True.

Return value

Boolean

Remarks

Project sets the order of years, months, and days in a date format equal to the corresponding value in the Regional and Language Options dialog box of the Windows Control Panel.

To make a copy of the active table, see the TableCopy method. To include options to wrap text within the table and use the Add New Column feature, see the TableEditEx method.

Example

The following example creates a new table based on the Task Usage table and adds the table to the Table drop-down menu. The macro adds the Priority field as the second column with a title and width of 12, changes the default date format, and then makes the new table the active view.

Sub CreateNewTaskUsageTable() 
 TableEdit Name:="Usage", TaskTable:=True, Create:=True, _ 
 NewName:="Priority Tasks" 
 
 TableEdit Name:="Priority Tasks", TaskTable:=True, _ 
 NewFieldName:="Priority", Title:="Priority", Width:=12, _ 
 ShowInMenu:=True, DateFormat:=pjDate_mm_dd_yy, _ 
 ColumnPosition:=1 
 
 TableApply "Priority Tasks" 
End Sub

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.