我的所有数据都是在Excel中准备的,最后一步是将数据传输到MS Project。在传输数据之前,我正在尝试编辑资源表中的表列。 (删除前3个默认列,自定义Text1并将Text1添加到资源表中的位置1)
- 以下代码是用Excel编写的 -
Dim Proj As MSProject.Application
Dim NewProj As MSProject.Project
Set Proj = New MSProject.Application
Set NewProj = ActiveProject
'Activate Resource Sheet
Proj.ViewApply Name:="Resource Sheet", SinglePane:=True
'Custom Resource Text1 to From
Proj.CustomFieldRename FieldID:=pjCustomResourceText1, NewName:="From"
'Delete First 3 Default Column
Proj.ColumnDelete
Proj.ColumnDelete
Proj.ColumnDelete
'-----------------------------------------------------------------------
'THIS CODE NEED HELP - It didn't add column to Resource Sheet,
' but add in Gantt Chart Sheet
Proj.TableEdit _
Name:="Entry", TaskTable:=True, NewFieldName:="Text1", _
Title:="From", Width:=6, Align:=1, _
ShowInMenu:=True, LockFirstColumn:=True, DateFormat:=255, _
RowHeight:=1, ColumnPosition:=1, AlignTitle:=pjCenter
Proj.TableApply Name:="Entry"
我不确定发生了什么/错误编码,你看到有什么错误。
答案 0 :(得分:0)
要编辑资源表(例如,资源工作表视图的Entry表),请将TableEdit方法的TaskTable参数设置为False:
Proj.TableEdit _
Name:="Entry", TaskTable:=False, NewFieldName:="Text1", _
Title:="From", Width:=6, Align:=1, _
ShowInMenu:=True, LockFirstColumn:=True, DateFormat:=255, _
RowHeight:=1, ColumnPosition:=1, AlignTitle:=pjCenter