none
How to delete every project's tasks with VBA RRS feed

  • Question

  • Hello,

    I need to reinitialize a project automatically : to delete every tasks  with VBA. How can I do that?

    NB : I have two levels in my WBS

    Thanks for your help

    Thursday, June 13, 2019 10:18 AM

Answers

All replies

  • Hi,

    does the following work or do I miss some special settings of your project?

    Sub DelTask()
    Dim T As Task
    Dim P As Project
    
    Set P = ActiveProject
    
    For Each T In P.Tasks
        If Not T Is Nothing Then
            T.Delete
        End If
    Next T
    End Sub

    Regards
    Barbara


    Barbara Henhapl Blog (English/German) MVP

    Thursday, June 13, 2019 10:28 AM
    Moderator
  • Hello Barbara,

    I don't have any very special setting in my project: only 2 levels in my WBS (around 200 work packages) but this sub, as mine is doing, deletes only the selected work package, and then it stops.

    Any idea?

    Thanks again

    Thursday, June 13, 2019 10:46 AM
  • Hi,

    sorry, no idea why it stops …

    Does this work:

    Sub Del2()
    Dim T As Task
    Dim P As Project
    
    Set P = ActiveProject
    For i = P.Tasks.Count To 1 Step -1
        Set T = P.Tasks(i)
        T.Delete
    Next i
    End Sub

    Regards
    Barbara


    Barbara Henhapl Blog (English/German) MVP

    • Marked as answer by WLID1966 Thursday, June 13, 2019 1:58 PM
    Thursday, June 13, 2019 11:13 AM
    Moderator