Fetching a Task by TaskID

S

Shishir

Hi,
I am unable to figure out how to fetch a task object
given an assignment.

Skeleton code for my intent.

For Each myResource In ActiveProject.Resources
For Each myAssignment In myResource.Assignments
' Here i'd like to know if the task is
' is a summary one or not.
' If I could get the task object, i'd like
' to use `myTask.Summary` for internal logic.
Next
Next

Any help is much appreciated.

thanks,
-shishir
 
J

Jack D.

Shishir said:
Hi,
I am unable to figure out how to fetch a task object
given an assignment.

Skeleton code for my intent.

For Each myResource In ActiveProject.Resources
For Each myAssignment In myResource.Assignments
' Here i'd like to know if the task is
' is a summary one or not.
' If I could get the task object, i'd like
' to use `myTask.Summary` for internal logic.
Next
Next

Any help is much appreciated.

thanks,
-shishir

Sub Macro4()

Dim t As Task
Dim r As Resource
Dim a As Assignment
Dim tid As Integer

For Each r In ActiveProject.resources
For Each a In r.Assignments
tid = a.TaskID
Set t = ActiveProject.Tasks(tid)
If t.summary Then
MsgBox t.Name
'PUT YOUR CODE HERE
End If
Next a
Next r
End Sub
--
Please try to keep replies in this group. I do check e-mail, but only
infrequently. For Macros and other things check http://masamiki.com/project

-Jack Dahlgren, Project MVP
email: J -at- eM Vee Pee S dot COM


+++++++++++++++++++
 
S

shishir

Jack,
Thanks much the response. I tried it, and it seems to
work as expected on a Project Pro 2002.

When I try this on the server though, I run into
trouble. The line
Set t = ActiveProject.Tasks(tid)
gives me a RunTime error 1101.

Can't quite understand why. I tired your script
cut-and-past'ed.

Any help much appreciated.
thanks,
-shishir
 
J

Jack D.

What do you mean by "on the server"?
This code requires that Project is installed on the machine you are running
it on - so that it has access to the project VBA library.

-Jack
Jack,
Thanks much the response. I tried it, and it seems to
work as expected on a Project Pro 2002.

When I try this on the server though, I run into
trouble. The line
gives me a RunTime error 1101.

Can't quite understand why. I tired your script
cut-and-past'ed.

Any help much appreciated.
thanks,
-shishir



--
Please try to keep replies in this group. I do check e-mail, but only
infrequently. For Macros and other things check http://masamiki.com/project

-Jack Dahlgren, Project MVP
email: J -at- eM Vee Pee S dot COM


+++++++++++++++++++
 
S

Shishir

Jack,
Thanks for your response. I meant the Project 2002 server.
For whatever reason, the behaviour seems to be different
between the Project 2002 Pro installed on my win2k machine
and the Project 2002 server that i wanted to put the macro
in. VB seems to be installed correctly for all other
purposes.
Have been unable to figure out the difference, but then I
am hardly an expert.
thanks,
-shishir
 
J

Jack D.

Shishir said:
Jack,
Thanks for your response. I meant the Project 2002 server.
For whatever reason, the behaviour seems to be different
between the Project 2002 Pro installed on my win2k machine
and the Project 2002 server that i wanted to put the macro
in. VB seems to be installed correctly for all other
purposes.
Have been unable to figure out the difference, but then I
am hardly an expert.
thanks,
-shishir
Project Server consists of several components. The main one is the server
database.
To get tasks from the database you can use SQL server queries or calls
through the PDS.
Both of these are far different from the VBA in project.

If you intend on working with the database I suggest that you read two
documents which are included on your project CD
svrdb.htm and projdb.htm document the databases and give information on
working with them.
Read them carefully. If you are not familiar with databases, you may need to
find someone who is to help you.


-Jack Dahlgren, Project MVP
email: J -at- eM Vee Pee S dot COM


+++++++++++++++++++
 

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