VB Add Task Duration

C

Chris Molland

I have developed a VB application to add data into MS Project. I can create a
new task:

oProj = oProj.ActiveProject
oProj.Tasks.Add(NewTaskName.Text) 'From a text field

TaskCount = oProj.Tasks.Count

The user enters a number in a field (lets assume this is to represent days).
I understand that duration is measured in minutes. How do i convert the
user's entered number so the duration is correctly entered and calculated? I
currently have the following:

oProj.Tasks(TaskCount).Duration = DurationValue.Value 'From a number field.

Thank you.
 
C

Chris Molland

Thank you Rod,

I managed to get it to work using:

oProj = oProjApp.ActiveProject
TaskCount = oProj.Tasks.Count 'I assume my new task will always be the same
as Tasks.Count
oProjApp.SetTaskField(Field:="Duration",
Value:=NewTaskDuration.Value.ToString, TaskID:=TaskCount

Should I change this to your suggestion?

Thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top