manipulating Task collection in C#

J

jov

Hi All,

currently I use the following code to get and manipulate individual
tasks within the collection:

object MSPtasks = projectApp.InvokeMember("Tasks",
BindingFlags.DeclaredOnly |
BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.Instance | BindingFlags.InvokeMethod,
null, openProject, null);

foreach (object MSPtask in ((System.Collections.IEnumerable)MSPtasks))
{
//do stuff
}

however I would like to be able to index tasks directly in the
collection this functionality is not provided by the IEnumerable
interface does anyone have a suggestion as to how I could do this, or
another .Net object I could use with the Tasks collection?

thanks,
John
 
R

Rod Gill

The fastest way to interact with any Office application is with VB.
Dim tsk as MSProject.Task

for each tsk in ProjApp.activeproject.tasks
'Do stuff
next

does the job in VB: does that help you translate to C#?
 

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