Set Custom Field value - VBA 2007

C

Claudio Hidetoshi

Hi all, I'm trying to set a task Start date to a project custom field (date
field), based on user outline code choice.
Example: if the user select "Development" in outline field, I have to set
the project custom field with the Start date of a task named "Development".

Code:
strTask = pj.Tasks(1).GetField(Application.FieldNameToFieldConstant("Atual
Fase", pjTask))
bFound = Find(Field:="TaskName", Test:="contains", Value:=strTask,
Next:=True, MatchCase:=False)
If bFound Then
SetTaskField Field:="Atual Fase Start", Value:=pj.Tasks.Item(1).Start,
AllSelectedTasks:=False, Create:=False, TaskID:=CStr(pj.Tasks(1).ID),
ProjectName:=pj.Name
End If

Any idea ?
 
S

Sean

Try reposting this in microsoft.public.project.developer group.
There'll be more people who do coding and can respond to your query
there.

--Sean
 
S

Sean

Sorry, wrong tab. Forget I said that.

--Sean

Try reposting this in microsoft.public.project.developer group.
There'll be more people who do coding and can respond to your query
there.

--Sean
 
S

Sean

Now that I have a clearer head, I think the issue might be that
Project doesn't know where to put the value. I think you set the
strTask variable fine, and the code for bFound is good, but the
SetTaskField method I think comes too soon. The problem, I think, is
that VBA isn't told which task is going to change. Try adding a
SelectTaskField method before you use the SetTaskField method and see
if that helps.

--Sean
 
C

Claudio Hidetoshi

Hi Sean,
I found the problem. I was using:
SetTaskField method to alter an Enterprise Project Custom Field, and in
PS2007 it doesn't work with these fields.

Then I saw a Rod Gill post using SetField. Then the code becomes like this:
Call
ActiveProject.ProjectSummaryTask.SetField(FieldNameToFieldConstant("Atual
Fase Start"), Application.ActiveSelection.Tasks(1).Start)
This code is after the Find method, and working fine.

Thanks for your time and help friend.

Cláudio Hidetoshi.
Rio de Janeiro - Brazil.
 

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