Tuesday, June 22, 2010

QTP: Get an attachment from a Test in QC

Function getAttachmentFromQC(attachmentName)
Dim returnValue

Dim attachmentList
Set attachmentList = QCUtil.CurrentTest.Attachments.NewList ("")

For Each Attachment in attachmentList
Attachment.Load True, ""
If InStr(Attachment.FileName, attachmentName) Then
getAttachment = Attachment.FileName
End If
Next

End Function


Usage
This code imports the first sheet from a attached excel sheet
DataTable.ImportSheet getAttachmentFromQC("test_data.xls") ,1 ,1

No comments: