How to select a task by knowing the task object?

G

Greg Jimson

Hi,

I'd like the select a taks in the UI from code. I know for example the
myTask.ID oder myTask.UniqueID.

Thanks for any advice
Greg
 
J

Jim Aksel

Is this what you are lookng for?

Dim x as long
x=the uniqueID of some task...
ActiveProject.Tasks.UniqueID(x).start

Here "start" is any valid task property such as start, finish, cost,
duration...
--
If this post was helpful, please consider rating it.

Jim

Visit http://project.mvps.org/ for FAQs and more information
about Microsoft Project
 
J

Jan De Messemaeker

Hi,

I think you mean this:

Outlineshowalltasks
filterapply "All Tasks"
selectrow row:=thetask.id,rowrelative=false

The only alternative is to run to the visible tasks (usindg selectall, then
activeselection.tasks) and check the row of the task you need.

Hope this helps,
 
J

Jack Dahlgren

Jan,

This assumes that the project is sorted by task id.
I think using find is more reliable:

Find Field:="ID", Test:="equals", Value:=thetask.id, Next:=True,
MatchCase:=False

This will find the task within the project based on the id that you send it.
You can use name or other criteria as well.

-Jack Dahlgren

Jan De Messemaeker said:
Hi,

I think you mean this:

Outlineshowalltasks
filterapply "All Tasks"
selectrow row:=thetask.id,rowrelative=false

The only alternative is to run to the visible tasks (usindg selectall,
then activeselection.tasks) and check the row of the task you need.

Hope this helps,
 
J

Jan De Messemaeker

Hadn't thought of that! Excellent, I'll never forget it.

--
Jan De Messemaeker
Microsoft Project MVP
http://users.online.be/prom-ade
Jack Dahlgren said:
Jan,

This assumes that the project is sorted by task id.
I think using find is more reliable:

Find Field:="ID", Test:="equals", Value:=thetask.id, Next:=True,
MatchCase:=False

This will find the task within the project based on the id that you send
it. You can use name or other criteria as well.

-Jack Dahlgren
 
J

Jack Dahlgren

Glad I could help.
I can not accept complete credit for it because someone here in the
newsgroups pointed it out to me.
Unfortunately I can no longer remember who showed me that trick...:)

-Jack Dahlgren
 
G

Greg Jimson

Hi,

thanks. I assume that this is not very fast, right?

Best
Greg

--
Greg Jimson
Jack Dahlgren said:
Jan,

This assumes that the project is sorted by task id.
I think using find is more reliable:

Find Field:="ID", Test:="equals", Value:=thetask.id, Next:=True,
MatchCase:=False

This will find the task within the project based on the id that you send
it. You can use name or other criteria as well.

-Jack Dahlgren
 
J

Jan De Messemaeker

Hi,

Probably not if you have a project with 10000s of tasks but I never saw it
being very slow.
 

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