Below is the Simple and working code that will log defect in Quality whenever encountered by your scripts.
Connects to Quality Center from a Quick Test test and adds a bug to the database.
Set TDConnection = CreateObject("TDApiOle.TDConnection")
TDConnection.InitConnection "http://yovav/tdbin" ' URL for the DB 'Enter the URL as per your server.
TDConnection.ConnectProject "TD76","bella","pino" ' Valid login information.Change Parameter like User Name and Password.
If TDConnection.Connected Then
MsgBox("Connected to " + chr (13) + "Server " + TDConnection.ServerName _
+ chr (13) +"Project " + TDConnection.ProjectName )
'Get the IBugFactory
Set BugFactory = TDConnection.BugFactory
'Add a new empty bug
Set Bug = BugFactory.AddItem (Nothing)
'Fill the bug with relevant parameters
Bug.Status = "New"
Bug.Summary = "Connecting to TD"
Bug.Priority = "4-Very High" ' depends on the DB
Bug.AssignedTo = "admin" ' user that must exist in the DB's users list'
Bug.DetectedBy = "admin" ' user that must exist in the DB's users list
'Post the bug to database (commit)