none
Loop through Tasks edit Scheduling Mode RRS feed

  • Question

  • Hi All, 

    I have a basic VBA script that I've put together to help me set summary tasks to Auto Scheduled mode. The idea is to only set summary tasks to "Auto Scheduled" and leave sub tasks as manually scheduled. 

    The code is written to loop through all the tasks and use the SetTaskMode method to change the schedule mode but the loop doesn't seem to be working and the scheduling mode only works for the active/selected tasks. I'm guessing it's something to do with the fact that the SetTaskMode works on the Application Object and not the Task Object which is what it being looped through.

    Does anyone have any thoughts on how to execute the idea? It will same significant time involved in manually selecting tasks and editing them in the Gannt Chart view.

    Code is below. 

    Thanks in advance!!

    Sub summary()
    Dim sumYes As Variant
    Dim i As Long
    Dim t As Task

    Set ts = ActiveProject.Tasks



    For i = 1 To 2139
    Set t = ts(i)
        If Not t Is Nothing Then
        sumYes = t.GetField(FieldNameToFieldConstant("Summary"))
            If sumYes = "Yes" Then
                Application.SetTaskMode Manual:=False
            End If
        End If
        

    Next i

    End Sub

    Thursday, July 18, 2019 3:02 AM

All replies

  • Hi,

    try the following, it is a bit easier:

    Sub ScheduleMode()
    Dim T As Task
    For Each T In ActiveProject.Tasks
        If Not T Is Nothing Then
            If T.Summary Then
                T.Manual = False
            End If
        End If
    Next T
    End Sub

    Regards
    Barbara


    Barbara Henhapl Blog (English/German)

    Thursday, July 18, 2019 5:12 AM
    Moderator
  • Nice try with the VBA, Rory,

    but I would just filter for summaries, then set the first, the shift ctrl down arrow to select and fill down (ctrl-D).

    Thursday, July 18, 2019 8:45 AM
  • roryTriesVBA --

    It makes no sense to me that you would use Auto Scheduled summary tasks with Manually Scheduled detailed tasks and milestone.  Maintaining a project schedule with Manually Scheduled tasks can be an absolute nightmare because Microsoft Project does not reschedule tasks automatically when a Predecessor task slips.  This means YOU must manually reschedule all of the Manually Scheduled tasks.

    Why don't you convert all tasks to Auto Scheduled and skip the whole VBA thing?  Let Microsoft Project automatically schedule every task in your project, and let the software tell you when every task will start and finish, based on Duration estimates and task dependency relationships.  Just a thought.  Hope this helps.


    Dale A. Howard [MVP]

    Thursday, July 18, 2019 9:26 PM
    Moderator