Monday, June 3, 2013

VBA code for Generating defects from QC without Queries


'Below mentioned is the code that can be utilized to get connected with QC and also generating the defects from 'the QC using VBA code
 
 
'This function will help you to get connected with Qualitty Center
 
Public Function QualityCenterConnection(ByVal qserver, qDomainName, qProjectname)
 
qusername = "username"
 
qpassword = "password"
 
Dim QCConnection
 
'Return the TDConnection object.
Set QCConnection = CreateObject("TDApiOle80.TDConnection")
 


QCConnection.InitConnectionEx qserver
 


'Login into Username and password

' Set the column names.

QCConnection.login qusername, qpassword
 
''Pass Domain Name and Project Name
QCConnection.Connect qDomainName, qProjectname
 
Set ConnectToQC = QCConnection

End function


Public Function exportreport()
Dim qserver As String
Dim qusername As String
Dim qpassword As String


qserver = "http://server name/qcbin"
 

qDomainName = "Domain Name"
 

qProjectname = "Project Name"

Dim QCConnection


Set QCConnection = QualityCenterConnection(qserver, qDomainName, qProjectname)


Set bfact = QCConnection.BugFactory

' Get a list of all the defects.
Dim BugFactory, BugList
 
Set BugFactory = QCConnection.BugFactory
 
Set BugList = BugFactory.NewList("")
 
'You can choose any other value that you want as per your need and requirements.
 
Cells(1, 1).Value = "Bug Id"
 
Cells(1, 2).Value = "Summary"
 
Cells(1, 3).Value = "Detected By"
 
Cells(1, 4).Value = "Priority"
 
Cells(1, 5).Value = "Status"
 
Cells(1, 6).Value = "Assigned To"
 
' Retrieve the values of each bug in excel sheet
 
Dim Bug, Row
Row = 2
For Each Bug In BugList
   Cells(Row, 1).Value = Bug.Field("BG_BUG_ID")
   Cells(Row, 2).Value = Bug.Summary
   
   Cells(Row, 3).Value = Bug.DetectedBy
   
   Cells(Row, 4).Value = Bug.Priority
   
   Cells(Row, 5).Value = Bug.Status
   
   Cells(Row, 6).Value = Bug.AssignedTo
   
     Row = Row + 1
Next

End function

No comments:

Post a Comment