Jack - How can I modify your code to move dependencies also?

L

lamby74

Jack - I love your code - I am finding it is making my life easier as far as
MSP is concerned. This is a piece of your code that moves all selected tasks
out a week:

Sub AddAWeekToMe()
For Each Task In ActiveSelection.Tasks
If Not Task.ConstraintDate = "NA" Then
Task.ConstraintDate = Task.ConstraintDate + 7
Else: Task.ConstraintDate = Now()
End If
Next Task
End Sub

Does anyone know if there is a way to add code to this so that any
accidentally un-selected dependencies (successors) will move with the
selected tasks? i want it to automatically shove out (or in, depending on if
using add a week, subtract a week, etc) successors?
Thanks - Lamby
 
J

Jan De Messemaeker

Hi,

Successores do automatically "shove out" when the predecessor is moved.
HTH
 
J

JackD

Jan is correct. The dependencies in your schedule should cause the
successors to move out as well.

You should note that this macro is specifically for tasks which have
constraints on them already. In general it is a bad idea to use constraints
instead of a chain of dependencies, but sometimes you need to do it.

I actually wrote a macro to help out in this situation as well. Rather than
using constraints (or a lag on the dependencies) to set a number of
milestones a certain distance apart, this macro simply lengthens the
milestone until it is as long as the duration from the finish of the
predecessor milestone to its finish. All these schedule moving and modifying
macros should be used with extreme caution.

Sub MilestonesToTasks()
Dim t, t2 As Task
Dim ts As Tasks
Dim d As Long

Set ts = ActiveProject.Tasks

For Each t In ts
For Each t2 In t.SuccessorTasks
If t2.Duration = 0 Then
d = Application.DateDifference(t.Finish, t2.start, Standard)
t2.Duration = t2.Duration + d + 1
t2.ConstraintType = pjASAP
End If
Next t2
Next t

End Sub
 
J

johnny nui

Hi Lamby,

I have been reading your posts with interest, but I never seem to see if
the suggested solution worked.
Could you please post your findings as well? It would help me out since I am
learning too.

thanks

johnny
 
L

liu

hi,

do you all creating the .mpp file without using the Microsoft Project? Do
you all know how to do it? Currently, im doing research to find out the way
of creating the .mpp file with vb/vb.net.

if you know how to create the .mpp file, can you teach me.
please post the complete code of creating the .mpp file so that i can follow
or just email to me, (e-mail address removed)

thanks alot

liu
 
L

liu

but i found this Microsoft.Office.Interop.MSProject.ApplicationClass
reference in Project which i can use it and by set reference to this dll, im
able to create a .mpp file but i don't know how to add other info to it, such
as resources, task and so on...
 
J

JackD

You need Project installed to use it.
That is what I meant.
I think that you should go to project, hit the F11 key and use the object
browser to look at all the available objects, methods properties. Also look
at the Project VBA help.
 

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