Error using Setfield - Project 2007

M

Madelein

Hi

I have used the following sample provided

fieldID=Application.FieldNameToFieldConstant(FieldName, FieldType)

MSGBOX(ActiveProject.ProjectSummaryTask.GetField(fieldID))

ActiveProject.ProjectSummaryTask.SetField(fieldID,"my value"))

the Getfield method is working but I keep getting an error on the
Setfield method:

"Compile error: Expected: ="

I have searched all over but cannot find a solution.

Please help!!

Thanks!
 
R

Rod Gill

Hi,

Only use parentheses with functions returning values, as in your getfield
example. SetField is not returning any value that you are using so use:

ActiveProject.ProjectSummaryTask.SetField fieldID,"my value"

I also note that you had two )) and only one (

To read or write built in fields, use:

ActiveProject.ProjectSummaryTask.text1="Sample Data"



--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com
 
L

Lapshin Poul

I try to use this:

FieldID = Application.FieldNameToFieldConstant("Text1", pjTask)
MsgBox (ActiveProject.ProjectSummaryTask.GetField(FieldID))
ActiveProject.ProjectSummaryTask.SetField FieldID:=FieldID, Value:="1"

and it is work.
 
M

Morne Taljaard

Lapshin said:
I try to use this:

FieldID = Application.FieldNameToFieldConstant("Text1", pjTask)
MsgBox (ActiveProject.ProjectSummaryTask.GetField(FieldID))
ActiveProject.ProjectSummaryTask.SetField FieldID:=FieldID, Value:="1"

and it is work.


I got this working, was a bit of a stupid mistake from my side.
 

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