Search code examples
excelalmvba

ALM Defects list failing with 'User defined type not defined'


I wanted to extract list of defects using a filter criteria. I tried the VBA code from OTA here, but compile fails on the following declarations with User defined type not defined:

Dim BugFact As BugFactory
Dim BugFilter As TDFilter
Dim bugList As List
Dim theBug As Bug

Note: I do not have administrative privileges on ALM.

The full VBA code:

Sub BugFilter()

    Dim BugFact As BugFactory
    Dim BugFilter As TDFilter
    Dim bugList As List
    Dim theBug As Bug
    Dim i%, msg$

' Get the bug factory filter.
    'tdc is the global TDConnection object.
    Set BugFact = tdc.BugFactory
    Set BugFilter = BugFact.Filter

' Set the filter values.
    BugFilter.Filter("BG_STATUS") = "Closed"
    BugFilter.order("BG_PRIORITY") = 1
    MsgBox BugFilter.Text

'Create a list of defects from the filter
' and show a few of them.
    Set bugList = BugFilter.NewList
    msg = "Number of defects = " & bugList.Count & Chr(13)
    For Each theBug In bugList
       msg = msg & theBug.ID & ", " & theBug.Summary & ", " _
          & theBug.Status & ", " & theBug.Priority & Chr(13)
       i = i + 1
       If i > 10 Then Exit For
    Next
    MsgBox msg

End Sub

Solution

  • You need to add a reference to the OTA COM Type library (see here); otherwise your program will not know about the OTA types such as BugFactory and TDFilter.