| || |
How to down load excel attachment from QC to Local
I am using the following code for downloading the test data file from Quality Center to Local machine. it was working earlier. now it is giving an error.
PathFinder.Locate is not returning any value to strPath variable.
strFile = "TestData"
strQCTestData = "[QualityCenter] Subject\Test Project\Input Test Data\TestData.xls"
strPath = PathFinder.Locate(strQCTestData)
Set objFSO = CreateObject("Scripting.FileSystemObject")
If (objFSO.FileExists( strFilePath & "\" & strFile & ".xls")) Then
objFSO.DeleteFile(strFilePath & "\" &strFile & ".xls")
objFSO.copyFile strPath, strFilePath & "\" & strFile &".xls"
fnDownloadTestData = strFilePath & "\" & strFile & ".xls"
Thanks and Regards,
Re: How to down load excel attachment from QC to Local
Take a look at recoding using the QCUtil and the AttachmentFactory in the QTP documention.
The code would look something like this:
' look for an attachment on the testset
Set CurrentTestSet = QCUtil.CurrentTestSet
Set AttachmentFactory = CurrentTestSet.Attachments
Set AttachmentList = AttachmentFactory.NewList("")
hold_field = AttachmentList.Count
For i_loop_counter = 1 To AttachmentList.Count
Set Attachment = AttachmentList.Item(i_loop_counter)
attached_xls = Attachment.Filename
If Right(attached_xls, 4) = ".xls" Then
attachmentfound = 1
t_Time = FormatDateTime(Time, 4)
Reporter.ReportEvent micPass, "Attachment Found", "Attachment from TestSet used. Time Started: " & t_Time & "."
Attachment.Load True, "C:\"
datatable.ImportSheet attached_xls,w_spreadsheetArray(0), "Action1"
datatable.ImportSheet attached_xls,w_spreadsheetArray(1), "Global"