Hi,

My requirement is to attach a word doccument to the first test case of the test set(scenario). i tried the below code but its attaching to folder not to the scenario test case.

Kindly help me
Sub attachment()
Dim QCConnection

Dim attachFact

Dim theAttachment

Dim attachList

Dim AttachmentList()

Dim HasAttachs


Set QCConnection = CreateObject("TDApiOle80.TDConnection")


QCConnection.InitConnectionEx server
QCConnection.Login Username,Password

QCConnection.Connect Domain,Project
Set TSetFact = QCConnection.TestSetFactory

Set tsTreeMgr = QCConnection.TestSetTreeManager

nPath = "Root\....\delete_me"

Set tsFolder = tsTreeMgr.NodeByPath(nPath)
Set tsff = tsFolder.TestSetFactory.Filter
Set tsl = tsff.NewList()
scn = "S3_R201SUS_A_CCO"
For j = 1 To tsl.Count
If scn = tsl(j).Name Then
Item = j
Exit For
End If
Next j
MsgBox Item

Set tsl = tsff.NewList()
Set ts = tsl.Item(Item)

Set attachFact = ts.Attachments

Set attachList = attachFact.NewList("")

For Each theAttachment In attachList

MsgBox theAttachment.Filename
MsgBox theAttachment.DirectLink
Next


If Not HasAttachs Then

Set theAttachment = attachFact.AddItem(Null)

theAttachment.Filename = "C:\Qc Test\somefile.txt"

TDATT_FILE = 1

theAttachment.Type = TDATT_FILE

theAttachment.Post

End If
On Error Resume Next
ReDim Preserve AttachmentList(attachList.Count - 1)



i = LBound(AttachmentList)


For Each theAttachment In attachList

AttachmentList(i) = theAttachment.ServerFileName

i = i + 1

Next


Dim fName

For Each fName In AttachmentList

MsgBox "The AttachmentList element is " & fName

Next

'QCConnection.SendMail "", "", "Test", "Hello", AttachmentList

MsgBox "bye"

'QCConnection.Disconnect
'QCConnection.Logout
'Set QCConnection = Nothing
End Sub