Update cost field

A

Adel

ehile trying to update the value of cost for Task # 1 in MS project, I got
the following Error (the argument value is not valid) when executing
the command

objPrj.Projects(PrjFileName).Tasks(0).SetField(MSProject.PjField.pjTaskCost,
"1000000")


The code


Dim x As Integer
Dim PrjFileName As String
Dim objPrj As MSProject.Application
Dim filename As String

objPrj = New MSProject.Application 'Create an instance


With DataSet11.Tables(0)

PrjFileName = .Rows(0).Item(1)

Call objPrj.Alerts(False)
objPrj.DisplayAlerts = False

objPrj.FileOpen(Name:=PrjFileName, ReadOnly:=False,
UserID:="<USERID>", DatabasePassWord:="<PASSWORD>", noAuto:=True, openPool:=4)



objPrj.Projects(PrjFileName).Tasks(0).SetField(MSProject.PjField.pjTaskCost,
"1000000")

objPrj.Projects(PrjFileName).Tasks(0).SetField(MSProject.PjField.pjTaskStart,
"1/1/2001")

objPrj.Projects(PrjFileName).Tasks(0).SetField(MSProject.PjField.pjTaskFinish, "1/1/2002")
 
J

Jan De Messemaeker

Hi,

Task Cost is a calculated field, and even more so for a summary task.
It cannot and should not accept a direct input.
HTH

--
Jan De Messemaeker, Microsoft Project Most Valuable Professional
http://users.online.be/prom-ade/
For FAQs: http://www.mvps.org/project/faqs.htm
Adel said:
ehile trying to update the value of cost for Task # 1 in MS project, I got
the following Error (the argument value is not valid) when executing
the command

objPrj.Projects(PrjFileName).Tasks(0).SetField(MSProject.PjField.pjTaskCost,
"1000000")


The code


Dim x As Integer
Dim PrjFileName As String
Dim objPrj As MSProject.Application
Dim filename As String

objPrj = New MSProject.Application 'Create an instance


With DataSet11.Tables(0)

PrjFileName = .Rows(0).Item(1)

Call objPrj.Alerts(False)
objPrj.DisplayAlerts = False

objPrj.FileOpen(Name:=PrjFileName, ReadOnly:=False,
UserID:="<USERID>", DatabasePassWord:="<PASSWORD>", noAuto:=True, openPool:=4)
objPrj.Projects(PrjFileName).Tasks(0).SetField(MSProject.PjField.pjTaskCost,
objPrj.Projects(PrjFileName).Tasks(0).SetField(MSProject.PjField.pjTaskStart
,
"1/1/2001")
objPrj.Projects(PrjFileName).Tasks(0).SetField(MSProject.PjField.pjTaskFinis
h, "1/1/2002")
 
A

Adel

I solved it.
use following
objPrj.SetTaskField("FixedCost", PFixedCost, , , "1", PrjFileName)
 
J

Jan De Messemaeker

Hi,

Of course: fixed cost is NOT a calculated field so you can updtae it.
HTH
 

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