Private Sub PurgeDraftRuns(Optional tsName As Variant) ' Purge draft runs Dim tsFact As ITestSetFactory Dim runFact As IRunFactory Dim tsFilter As ITDFilter Dim runFilter As ITDFilter Dim oList As IList Dim tsFilterText As String 'If no test set name passed, purge all draft runs. If IsMissing(tsName) Then tsFilterText = "" 'Otherwise, purge only the draft runs that 'match the tsName argument. Else Set tsFact = tdc.TestSetFactory Set tsFilter = tsFact.Filter tsFilter.Filter("CY_CYCLE") = tsName tsFilterText = tsFilter.Text End If Debug.Print tsFilterText 'Set up filter for draft runs Set runFact = tdc.RunFactory Set runFilter = runFact.Filter runFilter.Filter("RN_DRAFT") = "Y" Dim KeepLast Dim DateUnit Dim UnitCnt Dim StepsOnly KeepLast = 1 ' Keep last one draft run from each test set ' Non-draft runs are not purged because of the ' filter. DateUnit = 1 ' Days UnitCnt = 0 ' 0 days indicates runs from today and back StepsOnly = False ' Purge runs, not just steps tdc.PurgeRuns2 tsFilterText, runFilter.Text, _ KeepLast, DateUnit, UnitCnt, StepsOnly End Sub