'Code to add/upload business component into QC
'Note:to use this code Extended Storage Object has to be enabled in site Admin
sub add_comp()
qcUser = ""
qcPassword = ""
Domain = ""
Project = ""
qcServer = "http://qcHostName:qcPort/qcbin"
Set tdc = CreateObject("TDApiOle80.TDConnection")
tdc.InitConnectionEx qcServer
tdc.Login qcUser, qcPassword
tdc.Connect Domain, Project
Set objCompFldrFact = tdc.ComponentFolderFactory
Set rootCompFldr = objCompFldrFact.Root
Set compFactory = rootCompFldr.ComponentFactory
' Add the component
compName = "Test_comp"
Set myComp = compFactory.AddItem(Null)
Dim errString As String
If (compFactory.IsComponentNameValid(compName, errString)) Then
myComp.Name = compName
' myComp.ExtendedStorage (0)
myComp.ScriptType = "QT-SCRIPTED"
myComp.ApplicationAreaID = 897
myComp.Post
Set extStor = myComp.ExtendedStorage(0)
extStor.ClientPath = "C:\Backup\ECC\Login"
extStor.Save "-r *.*", True
Else
myComp.Name = "DefaultValidName"
MsgBox errString
End If
'Loads all the files from the directory
myComp.Post
'addding parameters to the added component
Set compParamFactory = myComp.ComponentParamFactory
Set compParam1 = compParamFactory.AddItem(Null)
compParam1.IsOut = 0 'false
compParam1.Name = compName
compParam1.desc = "Description for test parameter"
compParam1.ValueType = "String"
compParam1.Order = 1
compParam1.Post
Set compParam1 = Nothing
Set compParamFactory = Nothing
Set extStor = Nothing
Set myComp = Nothing
Set objCompFldrFact = Nothing
Set rootCompFldr = Nothing
Set compFactory = Nothing
'Disconnect from the project
If tdc.Connected Then
tdc.Disconnect
End If
''Log off the server
If tdc.LoggedIn Then
tdc.Logout
End If
''Release the TDConnection object
tdc.ReleaseConnection
Set tdc = Nothing
end sub