根据任务的小时数禁用MS Project自动更改任务的开始和结束日期。(宏) [英] Disable MS Project automatic changing of start and finish dates of a task based on hours of the task.(Macro)

查看:95
本文介绍了根据任务的小时数禁用MS Project自动更改任务的开始和结束日期。(宏)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Gurus,



我正在使用excel数据中的数据创建mpp文件。写在excel文件中的宏用于创建mpp文件。



以下我引用了参考的示例代码。

Hello Gurus,

I am creating mpp files using data from a excel data. macro written in the excel file is used to create the mpp files.

below i have quoted sample code for ref.

Set pjApp = CreateObject("MSProject.Application")
pjApp.FileNew 
Set newproj = pjApp.ActiveProject
......
......
newproj.Tasks.Add (task_name)
newproj.Tasks.(mpp_row_number).type = "2" ' value 2 for fixed work type
newproj.Tasks(mpp_row_number).Start = task_start_date
newproj.Tasks(mpp_row_number).Finish = task_end_date
newproj.Tasks(mpp_row_number).Hours = work_hours
newproj.Tasks(mpp_row_number).ResourceNames = resource_name
....
....
pjApp.FileSaveAs mpp_file_save_path & mpp_file_name & ".mpp"
pjApp.FileClose
pjApp.Quit

我的问题是,我没有在生成的mpp中获得正确的开始和结束日期文件。它会根据分配给任务的小时数自动更改开始日期或结束日期。如果我没有分配任务的小时数,那么
它是完美的。我的所有任务都是"固定工作"类型。



我的要求是,我有任务的开始日期,完成日期和总小时数。在给定的开始日期之前,资源必须工作很长时间。



例子b

案例1 。 



开始日期:2014年1月1日 



结束:2014年1月31日



小时:180小时



这里的资源从2014年1月1日起180小时工作到2014年1月31日。



案例2. 



开始日期:2014年3月1日  ; b


结束:2014年3月31日



小时:80小时



此资源在2014年3月1日至2014年3月31日期间仅工作80小时。



有人请帮忙根据分配的小时数禁用任务的开始和结束日期的自动更改。我很担心这个问题。



任何支持都表示赞赏。

My problem is that, I am not getting the right start and finish date for a task in the generated mpp file. it is automatically changing either start or finish date based on the hours assigned to the task. If i am not assigning the hours of the task then it is working perfect. All my task are of type "fixed work"

my requirement is that, i have a start date, finish date and total hours for the task. resource has to work that much hours for the given start an finish date.

example

case 1. 

start: 01-Jan-2014 

end : 31-Jan-2014

Hours : 180 hours

Here the resource has work 180 hours from 01-Jan-2014 to 31-Jan-2014.

case 2. 

start: 01-Mar-2014 

end : 31-Mar-2014

Hours : 80 hours

Here the resource has work 80 only hours from 01-Mar-2014 to 31-Mar-2014.

Somebody please help to disable the automatic change of start and finish date of a task based on hours assigned. I am stuck up with the issue.

Any support is appreciated.

推荐答案

Syamku,

Syamku,

您的方法存在一些问题。主要问题是您试图控制项目工作方程的所有三个部分。工作方程是:

There are a couple of things wrong with your approach. The main issue is that you are attempting to control all three parts of Project's work equation. The work equation is:

持续时间=工作/单位

您正在尝试通过指定开始日期和结束日期来设置持续时间。您还需要为一个资源(单位)设置工作值。

You are attempting to set the duration by specifying both the start and finish dates. You also want to set the work value for one resource (unit).

默认情况下,Project将新任务的持续时间设置为一天。如果输入开始日期,将设置start-no-early-than约束,Project将自动计算完成日期,但是在下午5:00。如果您随后输入不同的
完成日期,Project将设置完成 - 不晚于约束并自动将开始日期移动为8小时(记住持续时间仍然是默认的1天),之前完成日期。这是第一个问题。你是如何解决的?通过输入开始
日期和持续时间。请勿输入完成日期,Project将使用工作日历计算。您仍然会在任务上以不早于约束的开头结束,因此您可能需要单独处理,因为约束不允许Project
创建动态计划。

By default Project sets the duration of a new task to one day. If you enter the start date, a start-no-earlier-than constraint will be set and Project will automatically calculate the finish as the same day, but at 5:00 pm. If you then enter a different finish date, Project will set a finish-no-later-than constraint and automatically move the start date to be 8 hours, (remember the duration is still at the default 1 day), before the finish date. That's the first issue. How do you solve it? By entering a start date and a duration. Do NOT enter a finish date, Project will calculate that using the work calendar. You will still end up with a start-no-earlier-than constraint on the task so you may need to deal with that separately since constraints do not allow Project to create a dynamic schedule.

接下来,对于您想要的场景(即固定任务时间跨度和固定工作),您需要将任务设置为固定持续时间类型,而不是固定工作。这样您就可以获得所需的持续时间以及您想要的工作价值。项目将自动
在整个持续时间内线性扩展该工作值(即单位分配级别不为1,参考上述工作方程式)。但是,您可以手动(或通过代码)调整工作范围(即轮廓),例如,使用单个资源
正常工作8小时,但是在持续时间跨度内的任何时间,多天代表工作值。例如,假设您的持续时间为3周,但工作内容仅为40小时。您可以调整作业,使其完整的40小时工作
全部在第一周,最后一周或任何5天内完成。

Next, for your desired scenario (i.e. fixed task time span and fixed work), you need to set the task as a fixed duration type, not fixed work. That will allow you to have the duration you desire along with the work value you desire. Project will automatically linearly spread that work value over the entire duration, (i.e. the unit assignment level will NOT be 1, reference the above work equation). However, you can manually (or through code) adjust the work spread (i.e. contour) to, for example, have a single resource work a normal 8 hour day for however many days represent the work value anytime during the duration span. For example, let's say your duration is 3 weeks but the work content is only 40 hours. You could adjust the assignment to have the full 40 hours of work all done in the first week, the last week, or any 5 day span therein.

这就是它的工作原理。希望这会有所帮助。

That's how it works. Hope this helps.

John


这篇关于根据任务的小时数禁用MS Project自动更改任务的开始和结束日期。(宏)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆