2016-12-29 99 views
-1

我想使用過濾條件提取缺陷列表。我試圖從OTA here VBA代碼,但編譯失敗與用戶定義類型下面的聲明沒有定義ALM缺陷列表失敗,'用戶定義類型未定義'

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

注:我沒有在ALM管理權限。

完整的VBA代碼:

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 
+0

[用戶定義的類型未定義 - Excel宏]可能的重複(http://stackoverflow.com/questions/24261557/user-defined-type-not-defined-excel-macros) –

回答

1

您需要添加一個引用到OTA COM類型庫(見here);否則你的程序將不知道OTA類型,如BugFactoryTDFilter

+0

感謝Zev Spitz爲您的輸入。上述問題現已解決。但是現在在「Set BugFact = tdc.BugFactory」中獲得另一個錯誤,因爲Object需要 –

+0

如果答案已經解決了問題中的問題,請接受它(通過單擊答案旁邊的綠色複選框)。如果答案對你有幫助,然後點擊它(點擊答案旁邊的向上箭頭)。 –

+0

您可能需要初始化'tdc'對象:'Dim tdc As TDConnection: Set tdc = New TDConnection' –