如何将Excel的前身数据导出到MS项目?
我的工作簿中有四列。例如,ID列可以忽略。
ID | 任务名称 | 资源名称 | 前任 |
---|---|---|---|
1 | task1 | employee1 | 2 |
2 | subtask1 | employee2 | |
3 | task2 | employee1 | 4,5 |
4 | subtask2 | employee2 employee2 | |
5 | subtask3 | employeee2 |
我希望创建一个Excel宏以将内容导出到MS项目中。
我只能在网络中找到有关转移任务的共享。
我的代码,信用#madschedules,仅包括任务。
Sub createNewMSPFromExcelData()
' First go turn on the MS Project reference library
' Declare variables
Dim pjApp As MSProject.Application
Dim pjProject As MSProject.Project
Dim pjtasklist As MSProject.Tasks
Dim pjtask As MSProject.Task
'Dim pjpredlist As MSProject.TaskDependencies
'Dim pjpredlist As TaskDependencies
Dim pjpred As TaskDependency
Dim xlrange As Range
Dim xlrow As Long
Dim counter As Integer
'open MS Project application
Set pjApp = New MSProject.Application
pjApp.Visible = True
' Add a new project file
Set pjProject = pjApp.Projects.Add
Set pjtasklist = pjProject.Tasks
'Loop through all the Excel Data in the worksheet
counter = 2
Do Until Cells(counter, 1) = ""
Debug.Print Cells(counter, 1).Value & " " & Cells(counter, 2).Value & " " & Cells(counter, 3).Value
' Add new task into MS Project from Excel Value
pjtasklist.Add (Cells(counter, 2).Value)
pjpred.Add (Cells(counter, 3).Value)
counter = counter + 1
Loop
MsgBox ("There are " & pjtasklist.Count & vbNewLine & _
" tasks in our new project")
End Sub
为了回答有关前任的回答,我目前正在使用电子示意图设计的项目,该项目涉及多层结构。因此,要在层次结构上进行工作,我需要确保在继续下一个级别之前进行子层次结构活动,因此,我将前辈的细节从示意图中衍生成Excel。
I have four columns in my workbook. e.g. ID Column can be ignored.
ID | Task Name | Resource Names | Predecessors |
---|---|---|---|
1 | Task1 | Employee1 | 2 |
2 | SubTask1 | Employee2 | |
3 | Task2 | Employee1 | 4,5 |
4 | SubTask2 | Employee2 | |
5 | SubTask3 | Employee2 |
I am looking to create an Excel macro to export the contents into MS Project.
I can only find sharing in the web about transferring the Task.
My code, credit to #madschedules, only includes Tasks.
Sub createNewMSPFromExcelData()
' First go turn on the MS Project reference library
' Declare variables
Dim pjApp As MSProject.Application
Dim pjProject As MSProject.Project
Dim pjtasklist As MSProject.Tasks
Dim pjtask As MSProject.Task
'Dim pjpredlist As MSProject.TaskDependencies
'Dim pjpredlist As TaskDependencies
Dim pjpred As TaskDependency
Dim xlrange As Range
Dim xlrow As Long
Dim counter As Integer
'open MS Project application
Set pjApp = New MSProject.Application
pjApp.Visible = True
' Add a new project file
Set pjProject = pjApp.Projects.Add
Set pjtasklist = pjProject.Tasks
'Loop through all the Excel Data in the worksheet
counter = 2
Do Until Cells(counter, 1) = ""
Debug.Print Cells(counter, 1).Value & " " & Cells(counter, 2).Value & " " & Cells(counter, 3).Value
' Add new task into MS Project from Excel Value
pjtasklist.Add (Cells(counter, 2).Value)
pjpred.Add (Cells(counter, 3).Value)
counter = counter + 1
Loop
MsgBox ("There are " & pjtasklist.Count & vbNewLine & _
" tasks in our new project")
End Sub
To answer about the predecessors, I am currently doing a project with electronic schematic design which deals with multi hierarchies. Hence to work on the hierarchy, I need to ensure the sub-hierarchy activities are done before I can proceed with the next level, hence I have the predecessors details derived from the schematic into Excel.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
添加任务然后设置任务属性的关键是在添加任务对象后获取对任务对象的引用。因此,而不是:
在进行
进一步之前,需要清楚地了解任务,子任务和前任。在调度中,A 子任务被认为是摘要任务下的任务。摘要任务用于分组项目的任务的相关子集。摘要任务的开始和结束日期是根据其子任务的最早开始和最新完成的。
前任是必须在启动另一个任务之前必须发生的任务。前身任务几乎应该始终首先输入,以便时间表按时间顺序读取。因此,很少见到具有前身ID值高于其自己的任务。取而代之的是,Excel表会更好,例如OL = OL = OUTLINELEVEL:
this this this this this the典型的时间表结构,例如典型的时间表结构此:
最后,这是将上表变成时间表的代码:
The key to adding tasks and then setting task properties is to get a reference to the task object after it's added. So instead of:
do
Before going any further, however, clarity is needed regarding tasks, subtasks, and predecessors. In scheduling, a subtask is considered to be a task under a summary task. A summary task is used to group a related subset of the tasks for the project. The summary task's start and finish dates are calculated based on the earliest start and latest finish of its subtasks.
Predecessors are tasks that must happen before another task can start. Predecessor tasks should almost always be entered first so that the schedule reads in chronological order. Therefore it is extremely rare to see a task with a predecessor ID value higher than its own. Instead, the Excel table would be better like this where OL = OutlineLevel:
This yields the typical schedule structure like this:
And finally, here is the code to turn the table above into the schedule: