Hi All,
Thanks for reading this and Thanks in advance if you can resolve my problem.
I am very new to scripting thing. I am developing and excel vba to fetch defect data from QC.
QC link, Uid, Pswd, Detected_in_cycle will be passed as parameter through customization sheet in my excel.
Please look at the below code and let me know where am i going worng. I would be very much thankful if any1 could rectify this code.
Many Thanks
Sub defect_dump()
Dim time1
time1 = Timer
Application.Calculation = xlManual
Dim url As String
Dim qcConnectionObj
url = ActiveWorkbook.Sheets("Customization").Cells(4, 4)
Set qcConnectionObj = CreateObject("tdapiole80.tdconnection")
qcConnectionObj.InitConnectionEx (url)
qcConnectionObj.login ActiveWorkbook.Sheets("Customization").Cells(5, 4), ActiveWorkbook.Sheets("Customization").Cells(6, 4)
qcConnectionObj.Connect ActiveWorkbook.Sheets("Customization").Cells(7, 4), ActiveWorkbook.Sheets("Customization").Cells(8, 4)
MsgBox "Quality Centre Connected"
Call ExportDefects
'qcConnectionObj.Disconnect
'qcConnectionObj.Logout
'qcConnectionObj.ReleaseConnection
End Sub
Function ExportDefects()
Dim BugFactory, BugList, BgFilter
Set BugFactory = qcConnectionObj.BugFactory
Set BgFilter = BugFactory.Filter
BgFilter.Filter("BG_DETECTED_IN_RCYC") = ActiveWorkbook.Sheets("Customization").Cells(14, 4)
Set BugList = BugFactory.NewList("") 'Get a list of all the defects.
Dim Bug, Excel, Sheet
Set Excel = ActiveWorkbook.Sheets("Sheet2") 'Open Excel
'Excel.WorkBooks.Add() 'Add a new workbook
'Get the first worksheet.
Set Sheet = Excel.ActiveSheet
Sheet.Name = "Defects"
With Sheet.Range("A1:H1")
.Font.Name = "Arial"
.Font.FontStyle = "Bold"
.Font.Size = 10
.Font.Bold = True
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.Interior.ColorIndex = 15 'Light Grey
End With
Sheet.Cells(1, 1) = "Summary"
Sheet.Cells(1, 2) = "Detected By"
Sheet.Cells(1, 3) = "Detected on Date"
Sheet.Cells(1, 4) = "Status"
Sheet.Cells(1, 5) = "Subject"
Sheet.Cells(1, 6) = "Severity"
Sheet.Cells(1, 7) = "Priority"
Sheet.Cells(1, 8) = "Assigned To"
'Call PrintFields(BugFactory)
Dim Row
Row = 2
'Iterate through all the defects.
'For Each Bug In BugList and Bug.Filed("BG_USER_01").value="time"
'Save a specified set of fields.
Sheet.Cells(Row, 9).Value = Bug.Field("BG_BUG_ID")
Sheet.Cells(Row, 1).Value = Bug.Summary
Sheet.Cells(Row, 2).Value = Bug.DetectedBy
Sheet.Cells(Row, 3).Value = Bug.Field("BG_DETECTION_DATE")
Sheet.Cells(Row, 4).Value = Bug.Status
Sheet.Cells(Row, 5).Value = Bug.Field("BG_SUBJECT")
Sheet.Cells(Row, 6).Value = Bug.Field("BG_SEVERITY")
Sheet.Cells(Row, 7).Value = Bug.Priority
Sheet.Cells(Row, 8).Value = Bug.AssignedTo
Row = Row 1
'Next
Excel.Columns.AutoFit
'Save the newly created workbook and close Excel.
Excel.ActiveWorkbook.SaveAs ("C:\" & sProject & "_DEFECTS.xls")
Excel.Quit
End Function