none
Optimize the code of macro for MS Project RRS feed

  • Question

  • Hi,

    i made a macro for indetify to task whose predecessor Completed.

    Using "For Loop" like For Each tast in ActiveProject.tasks.

    But Problem is that ,this code is working fine with small plan,when i run this macro for a big plan then plan are not responding.

    Thanks in advance .. :)

    Pankaj


    pankaj keshari

    pankaj keshari AstrWix Noida
    Tuesday, December 20, 2011 2:36 PM

Answers

  • Hi,

    First, I just read in a different post that theremay be performance issues related to the status field.

    So try to avoid it by using instead

    if not tpred.percentcomplete=100 then

     

    Second, I'm a very impatient man so inside the loop I code an extra line

    statusbar=cstr(t.id) which allows me to foolow progress in the sttus bar

    Finally, maybe application.visible =false at the start and =true at the end may speed up (but you won't se ethe status bar :-(

    Greetings,

     

    Wednesday, December 21, 2011 11:03 AM
    Moderator

All replies

  • pankajkeshari,

    Without seeing you code it is impossible to tell what might be wrong. Also, what do you mean by "small plan" and "big plan"? If your "big plan" is a master/subproject structure simply looping through the tasks in the active project won't work.

    John

    Tuesday, December 20, 2011 3:28 PM
  • Can you also say which version of Project and what you mean by "won't work"? And yes, please post teh code and identify what part isn't working and what you want it to do.

    Rod Gill

    The one and only Project VBA Book Rod Gill Project Management
    Tuesday, December 20, 2011 9:43 PM
    Moderator
  • Hi john,

    Smal plan means those project plan which have 200-500 task and

    Big plan mens those have task in thosands..

    Code are given as below..

    Sub PankajTest()
     Dim ts As Tasks
     Dim t As Task
     Dim tPred As Task
       
    For Each t In ActiveProject.Tasks
       
          If t.BaselineStart <= dTodayDate And t.PercentWorkComplete <> 100 Then
            For Each tPred In t.PredecessorTasks
            t.Text25 = ""
            If tPred.Status <> pjComplete Then
               t.Text25 = "Predecessor Not Complete"
               Else: t.Text25 = ""
             End If
               Next tPred
            Else
            t.Text25 = ""
          End If
        Next t
    End Sub


    pankaj keshari Accenture
    Wednesday, December 21, 2011 5:52 AM
  • when i run the macro then ,, then MSP was not not respomding...

    MSP have nearly 5000 task..


    pankaj keshari Accenture
    Wednesday, December 21, 2011 5:54 AM
  • Hi,

    First, I just read in a different post that theremay be performance issues related to the status field.

    So try to avoid it by using instead

    if not tpred.percentcomplete=100 then

     

    Second, I'm a very impatient man so inside the loop I code an extra line

    statusbar=cstr(t.id) which allows me to foolow progress in the sttus bar

    Finally, maybe application.visible =false at the start and =true at the end may speed up (but you won't se ethe status bar :-(

    Greetings,

     

    Wednesday, December 21, 2011 11:03 AM
    Moderator