Hi Vasanth,
Please run this code on your end and let me know whether it is downloading the attachments.
Sub ExploreTestPlan() Sheet_1 = "Details" Sheet_2 = "Settings" Set tdc = CreateObject("TDApiOle80.TDConnection") Set objFile = CreateObject("scripting.FilesystemObject") tdc.InitConnectionEx Worksheets(Sheet_2).Cells(1, 2).Value tdc.Login Worksheets(Sheet_2).Cells(2, 2).Value, Worksheets(Sheet_2).Cells(3, 2).Value tdc.Connect Worksheets(Sheet_2).Cells(4, 2).Value, Worksheets(Sheet_2).Cells(5, 2).Value MsgBox "Connection Established" filePath = Worksheets(Sheet_1).Cells(1, 8).Value iLoop = 2 Do While Worksheets(Sheet_1).Cells(iLoop, 1).Value <> "" strPath = Worksheets(Sheet_1).Cells(iLoop, 1).Value testCaseName = Worksheets(Sheet_1).Cells(iLoop, 2).Value Filename = Worksheets(Sheet_1).Cells(iLoop, 3).Value If objFile.FileExists(filePath & "\" & Filename) Then Comments = Worksheets(Sheet_1).Cells(iLoop, 4).Value If Comments <> "" Then Comments = "Test" End If On Error GoTo 1 Set TreeMgr = tdc.TreeManager Set tsttr = TreeMgr.NodeByPath("Subject\" & strPath) Set tsetFact = tsttr.TestFactory Set tsetList = tsetFact.NewList("") blnFlag = False For Each tset In tsetList If tset.Name = testCaseName Then Set fVersionControl = tset.VCS fVersionControl.CheckOut -1, Comments, False Set attachmentFac = tset.Attachments Set Attachment = attachmentFac.AddItem(Null) Attachment.Filename = Filename Attachment.Description = Filename Attachment.Post Dim Attachmentcount As Integer Dim afact Dim alist As TDAPIOLELib.List Set afact = tset.Attachments Set alist = afact.NewList("") Attachmentscount = alist.Count MsgBox "Count of Attachments for the test set : " + CStr(Attachmentscount) Dim index1 As Integer Dim max1 As Integer Dim min1 As Integer min1 = 1 max1 = Attachmentscount index1 = Int((max1 - min1 + 1) * Rnd + min1) Dim attachment1 As TDAPIOLELib.Attachment Set attachment1 = alist.Item(index1) AttachmentID = attachment1.ID AttachmentName = attachment1.Name MsgBox "AttachmentID :" + CStr(AttachmentID) MsgBox "AttachmentName :" + CStr(AttachmentName) Dim theAttach Dim ExStrg Set theAttach = afact.Item(AttachmentID) If theAttach Is Nothing Then MsgBox "Attachment is not found" 'Exit Function End If If Not (theAttach.FileSize > 0) Then MsgBox "Attachment" + AttachmentName + "has zero size." 'Exit Function End If 'attachment1.Load True, "" 'theAttach.Load True, "" theAttach.Load True, "" MsgBox theAttach.Filename ' To get the path in VBScript, extract if from ' the filename: theFileName = theAttach.Filename thePath = Left(theFileName, InStrRev(theFileName, "\") - 1) 'these are the instructions to get the path where the file was download. i didn't try but this could be usefull. MsgBox thePath fVersionControl.CheckIn "", Comments Set ExStrg = Nothing Set Attachment = Nothing Set attachmentFac = Nothing Set fVersionControl = Nothing Worksheets(Sheet_1).Cells(iLoop, 5).Value = "Yes" blnFlag = True Exit For End If Next If Not blnFlag Then Worksheets(Sheet_1).Cells(iLoop, 5).Value = "Test Case not available in QC in the mentioned Path" End If Else Worksheets(Sheet_1).Cells(iLoop, 5).Value = "File Not exist in the path mentioned" End If 1: If Err.Number <> 0 Then Worksheets(Sheet_1).Cells(iLoop, 5).Value = "Invalid QC Path" End If iLoop = iLoop + 1 Loop Set TreeMgr = Nothing Set tsttr = Nothing Set tsetFact = Nothing Set tsetList = Nothing tdc.Disconnect tdc.Logout Set tdc = Nothing MsgBox "Macro Execution Completed" End Sub
Regards,
Srihari