05-29-2014, 02:08 PM
The following function will be useful :
Code:
Function DownloadAttachements(qtApp, tdc, testPath, strFSAPath)
For Each oTestSet In tdc.TreeManager.NodeByPath(testPath).TestFactory.NewList("")
ScriptName = oTestSet.Name
Script = "[QualityCenter] " & testPath & "\" & ScriptName
Dim otaAttachmentFactory
Dim otaAttachment 'As TDAPIOLELib.Attachment
Dim otaAttachmentList 'As List,
Dim TAttach 'As Attachment 'As TDAPIOLELib.List
Dim otaTreeManager 'As TDAPIOLELib.TreeManager
Dim otaSysTreeNode 'As TDAPIOLELib.SysTreeNode
Dim otaExtendedStorage, AttachDow
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Set otaAttachmentFactory = oTestSet.Attachments
Set otaAttachmentList = otaAttachmentFactory.NewList("")
'MsgBox "Attachment Count:" & otaAttachmentList.Count
If otaAttachmentList.Count > 0 Then
Set otaAttachment = otaAttachmentList.Item(1)
otaAttachment.Load True, ""
strPath = otaAttachment.Filename
DownloadAttachements = strPath
SysPathF = strFSAPath & "Attachments_" & oTestSet.Name
Call CreateFolder(SysPathF)
SysPath = SysPathF & "\"
Call CreateFolder(SysPath)
fso.CopyFile strPath, SysPath
Else
'MsgBox "Fail"
DowloadAttachment = "Empty"
End If
Set otaAttachmentFactory = Nothing
Set otaAttachment = Nothing
Set otaAttachmentList = Nothing
Set otaTreeManager = Nothing
Set otaSysTreeNode = Nothing
Set fso = Nothing
Next
End Function