Problem using EditGoTo in C#

J

John Svazic

Hi all,

I'm using the C# wrapper for the Project COM object, and it has an
EditGoTo method. However, this one requires me to pass in two
parameters, one for the ID and the other for the Date. Here's what
I've tried to no avail:

....
Task newTask = ...; // Create the new task.
projectApp.EditGoTo(newTask.ID, ""); // Doesn't work.
projectApp.EditGoTo(newTask.ID, null); // Doesn't work.
projectApp.EditGoTo(newTask.UniqueID, ""); // Doesn't work.
projectApp.EditGoTo(newTask.UniqueID, null); // Doesn't work.
....

The specific error I'm getting is:

The argument value is not valid.
at System.RuntimeType.ForwardCallToInvokeMember(String memberName,
BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData&
msgData)
at Microsoft.Office.Interop.MSProject._MSProject.EditGoTo(Object ID,
Object Date)
....

Any ideas? I've also tried the SelectTaskCell to no avail. I'm not
sure what I'm doing wrong here. Any help would be greatly appreciated.
 
J

John Svazic

Okay, it turns out that the "optional" values are still required to be
valid. So both of the following work:

projectApp.EditGoTo(newTask.ID, 0);
projectApp.EditGoTo(newTask.ID, DateTime.Now);
 
J

JackD

I'd avoid selecting tasks or going to tasks completely. What is it you are
trying to do? There might be an easier way in the object model.
 
R

Rod Gill

Hi,

C# needs all parameters specified. VB and vba have optional parameters which
is one reason why Office automation is much faster to code in vb or vba.
Jack is right tho, why are you selecting tasks? There is no need and it
slows your macro down considerably.
 

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