API文档不详细,摸索半天,终于找到解决办法:
Function uploadTestResultToQC
Set objPath = CreateObject("Scripting.FileSystemObject")
If Not objPath.FileExists("C:\test\test.xls") Then
msgbox "not exist file"
ExitTest
End If
Set objPath = nothing
Set ResourceFactory = QCConnection.QCResourceFactory '事先得连接上QC
Set ResourceFilter = ResourceFactory.Filter
ResourceFilter.Filter("RSC_NAME")="test.xls"
Set ResourceList = ResourceFilter.NewList
If ResourceList.Count >0 Then
For j=1 To ResourceList.Count
Set ResourceFile = ResourceList.Item(j)
If ResourceFile.name = "test.xls"Then
ResourceFile.FileName = "test.xls" 'API文档上有说明,事先得给一个filename
ResourceFile.post '必须先post一下,要不然上传不了
ResourceFile.UploadResource "C:\test\"&"",true '路径后面一定要加上"",要不然也上传不成功,这是最关键的两点
End If
next
End If
Set ResourceFile = nothing
Set ResourceFilter = nothing
Set ResourceFactory = nothing
end function