Finding Objects Quickly without loop thru all

M

Maurice Birchler

sIs there a quick method call to load an Microsoft Project Objects (like a
task or a resource) that matches a selection criteria?
For example I don't like having to loop through like:-
for each Task in Tasks
if Task.Text1 = "Special" then --- This is the one I want
Next Task
 
R

Rod Gill

For Text1 the only choices are to loop or first create then apply a filter
that finds all tasks with "Special" in Text1

For a task you can select by ID, Unique ID, or name. EG:

Activeproject.Tasks(10)
Activeproject.Tasks.UniqueID(10)
Activeproject.Tasks("Special")
 
J

JackD

Filtering is an effective way, but I've never found loops to be much of a
problem. They execute quite quickly.
If you know you only have one task / resource to find you can exit the loop
once you have found it. That way statistically you cut some time off the
loop - you might not have much gain in speed if the task is at the end of
the list though.
 
J

Jan De Messemaeker

Hi,

There is an other way - don't claim it is faster
Find ("Text1","equals","Special")
The task will then be selected and can be accessed as
Activeselection.tasks(1)
But mind you to find this MS Project will certainly loop through all tasks
:)
 

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