Inserting Tasks At A Specific Row (ID) Using Tasks Collection

J

jdelaney44

Hi.

Pretty sure I understand ActiveProject.Tasks.Add adds tasks at the
bottom of the schedule, gives the new task the next available UID and
ID.

What I would like to do is something like this -

1.) Find a task in the tasks collection (I can do this, no problem)
2.) Insert a new task "below" that one, realizing of course that
"below" in the collection is a virtual thing

The only way I can figure to do that is to something like this -

1.) Add the task
2.) Keep the task in something called NewTask
3.) Find the ID of the task I want to insert below (TaskIWantID)
4.) Walk down the entire task collection incrementing each ID greater
than TaskIWantID by one
5.) Set NewTask.ID = TaskIWantID + 1

Doesn't seem all that hard, but I wanted to see if there was another,
smarter, way to do this.

Note, I really don't want to use EditInsert, I'm trying to make this
less screen dependent.

If I need to go off into C# or something, that's cool too. I guess
I'll go hunting down that path next.

Thanks
John
 
J

Jack Dahlgren

ActiveProject.Tasks.Add has the following syntax:

Activeproject.tasks.add(Name, Before)

where before is a long specifing the position of the task you are inserting
it before.
If you leave out the before argument, then it puts the task at the end.

So for what you are doing get the id of the task you are working with, and
set the value for before to be that task's id +1 .

Example, you want it to be inserted after the fifth task:

activeproject.tasks.add("my new task", 6)

-Jack Dahlgren
 
M

Mike Glen

Hi John,

Next time, try posting on the microsoft.public.project.developer newsgroup.
Please see FAQ Item: 24. Project Newsgroups. FAQs, companion products and
other useful Project information can be seen at this web address:
http://project.mvps.org/faqs.htm

Mike Glen
Project MVP
 
J

jdelaney44

ActiveProject.Tasks.Add has the following syntax:

Activeproject.tasks.add(Name, Before)

where before is a long specifing the position of the task you are inserting
it before.
If you leave out the before argument, then it puts the task at the end.

So for what you are doing get the id of the task you are working with, and
set the value for before to be that task's id +1 .

Example, you want it to be inserted after the fifth task:

activeproject.tasks.add("my new task", 6)

-Jack Dahlgren














- Show quoted text -

Thanks very much. That just hasn't jumped out at me from the help
files. But, I just did some more poking around with that little tid
bit on the Add method and it does show up along with a whole bunch of
other interesting things about Add. I appreciate it very much.

Best,
John
 

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