[MSProject 2003] Fields automatically modified

B

Bridou

Hi,

I'm developing a plugin for MS Project 2003 and I have an error that I don't
understand.

I get task's data from external tool which is :
Start date : 27 March 2007
End date : 04 April 2007
Constraint type : ASAP

And now it depend how I write the code but some data is always changed, eg :

Example 1 :

tacheProject.ConstraintType =
Microsoft.Office.Interop.MSProject.PjConstraint.pjASAP;

tacheProject.Start = new DateTime(1970, 1, 1, 0, 0, 0,
0).AddSeconds(Tache.start_date);

tacheProject.Finish = new DateTime(1970, 1, 1, 0, 0, 0,
0).AddSeconds(Tache.end_date);

It results :
Start date : 27 March 2007
End date : 04 April 2007
Constraint type is equal to 6 which is NET I think

Now example 2 :

tacheProject.Start = new DateTime(1970, 1, 1, 0, 0, 0,
0).AddSeconds(Tache.start_date);

tacheProject.Finish = new DateTime(1970, 1, 1, 0, 0, 0,
0).AddSeconds(Tache.end_date);

tacheProject.ConstraintType =
Microsoft.Office.Interop.MSProject.PjConstraint.pjASAP;

It results :
Start date : 23 April 2007 (Current date in fact)
End date : 01 May 2007
Constraint type : ASAP

If I put the constraint before the dates, the constraint is modified.
If I put it after the dates, then it modifies the dates.

How can I fix the value I want without MS Project modifiy them ?

Thanks by advance,
Bridou
 
J

John

Bridou said:
Hi,

I'm developing a plugin for MS Project 2003 and I have an error that I don't
understand.

I get task's data from external tool which is :
Start date : 27 March 2007
End date : 04 April 2007
Constraint type : ASAP

And now it depend how I write the code but some data is always changed, eg :

Example 1 :

tacheProject.ConstraintType =
Microsoft.Office.Interop.MSProject.PjConstraint.pjASAP;

tacheProject.Start = new DateTime(1970, 1, 1, 0, 0, 0,
0).AddSeconds(Tache.start_date);

tacheProject.Finish = new DateTime(1970, 1, 1, 0, 0, 0,
0).AddSeconds(Tache.end_date);

It results :
Start date : 27 March 2007
End date : 04 April 2007
Constraint type is equal to 6 which is NET I think

Now example 2 :

tacheProject.Start = new DateTime(1970, 1, 1, 0, 0, 0,
0).AddSeconds(Tache.start_date);

tacheProject.Finish = new DateTime(1970, 1, 1, 0, 0, 0,
0).AddSeconds(Tache.end_date);

tacheProject.ConstraintType =
Microsoft.Office.Interop.MSProject.PjConstraint.pjASAP;

It results :
Start date : 23 April 2007 (Current date in fact)
End date : 01 May 2007
Constraint type : ASAP

If I put the constraint before the dates, the constraint is modified.
If I put it after the dates, then it modifies the dates.

How can I fix the value I want without MS Project modifiy them ?

Thanks by advance,
Bridou

Bridou,
Off the top of my head, what you see makes sense. Remember that when a
user manually enters a date into the Start or Finish fields, Project
will automatically set a constraint depending on which entry is made
first. That is exactly what is happening in your code. In the first
case, the last step effectively enters a finish date so Project sets a
FNET constraint. In the second case, the automatic constraints set by
Project are effectively cancelled when you set an ASAP constraint after
the dates have been entered.

Hope this helps.
John
Project MVP
 
B

Bridou

I understand your answer, but manually we are capable to fix a start date, an
end date and set a constraint : ASAP .

So how can I do that by coding ?

In project, if you put a start date and an end date, then modifiy the
constraint It doesn't chane the dates, am I wrong ?

In fact, to explain clearly, I'm working on a tool which exports tasks from
MS Project and import task to MS Project.
For now my goal is to export a project and get the same one if I re import it.
And unfortunately, I have this little problem... :(

Thanks anyway,
Bridou
 
J

Jan De Messemaeker

Hi,

Sorry, not true at all.
The manual changes give exactly the same result as the code.
Hope this helps,
 
R

Rod Gill

Best way to learn is to record a macro of you doing manually what you want, then convert to C#. Programming this in VB would be much quicker and easier to understand and run at exactly the same speed!

What you code does only what you can do manually, so first learn the correct steps and their sequence, then learn to code those steps.

--

Rod Gill
Project MVP

Project VBA Book, for details visit:
http://www.projectvbabook.com

NEW!! Web based VBA training course delivered by me. For details visit:
http://projectservertraining.com/learning/index.aspx


----------------------------------------------------------------------------------------------------


"Jan De Messemaeker" <jandemes at prom hyphen ade dot be> wrote in message Hi,

Sorry, not true at all.
The manual changes give exactly the same result as the code.
Hope this helps,
 
J

John

Bridou said:
I understand your answer, but manually we are capable to fix a start date, an
end date and set a constraint : ASAP .

So how can I do that by coding ?

In project, if you put a start date and an end date, then modifiy the
constraint It doesn't chane the dates, am I wrong ?

In fact, to explain clearly, I'm working on a tool which exports tasks from
MS Project and import task to MS Project.
For now my goal is to export a project and get the same one if I re import
it.
And unfortunately, I have this little problem... :(

Thanks anyway,
Bridou

Bridou,
Well, it sounds like you did NOT understand what I said. If the
constraint is applied, either manually or via VBA, after the date
information is set, then the "constraint" of ASAP remains (ASAP isn't
really a constraint - it is the opposite). But, if the constraint is set
before the date information is set, then the last date entered sets the
constraint (SNET for start entered last or FNET for finish entered last).

As far as how to do that with code, just follow that sequence. In your
code examples, the second example DID follow that sequence, the first
example did NOT follow that sequence.

Hope this clarifies.
John
Project MVP
 

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