Dear LEM visitors,

This is the first article of HP QC VBA Tutorial. Here I will teach you the first step which you should know before doing any automation related to Quality Center using Excel Macro. That first step is nothing but connecting to the Quality Center using excel macro. As you might have seen on the Quality Center UI (User Interface), Login to Quality Center consists of two steps:
1. Authenticate your User ID and Password
2. On Successful Authentication all the Domains and Projects appears in the below drop down
Quality Center Login (Authentication)
In the same way QC connection using VBA is also done in 2 steps:
First Authenticate your credentials (User ID and Password)
Then connect to QC using Domain and Project names.


Sub ConnectToQualityCenter()

Dim qcURL As String
Dim qcID As String
Dim qcPWD As String
Dim qcDomain As String
Dim qcProject As String
Dim tdConnection As Object

On Error GoTo err
   qcURL = <QC URL> 'Example : https://<server url>/qcbin
   qcID = <your User ID>
   qcPWD = <Your password>
   qcDomain = <Domain Name>
   qcProject = <Project Name>
'Display a message in Status bar
   Application.StatusBar = "Connecting to Quality Center.. Wait..."
' Create a Connection object to connect to Quality Center
   Set tdConnection = CreateObject("TDApiOle80.TDConnection")
'Initialise the Quality center connection
   tdConnection.InitConnectionEx qcURL
'Authenticating with username and password
   tdConnection.Login qcID, qcPWD
'connecting to the domain and project
   tdConnection.Connect qcDomain, qcProject
'On successfull login display message in Status bar
   Application.StatusBar = "........QC Connection is done Successfully"
   Exit Sub
'Display the error message in Status bar
Application.StatusBar = err.Description
End Sub

URL which you are passing, should always be till https://<server url>/qcbin only.
Using above code, now you are connected with Quality center for a given Domain and project. Object tdConnection as defined above can be used to access each and every objects available in the Quality Center, like Test Cases, Requirements, Defects etc.

In coming articles, we will learn about the objects inside the quality center after authentication is successful.