如何使用VBA将文件附加到QC?
我得到一个运行时错误: “-2147219913(80040637)自动错误如何使用VBA将文件附加到QC?,vba,filesystemobject,hp-quality-center,Vba,Filesystemobject,Hp Quality Center,我得到一个运行时错误: “-2147219913(80040637)自动错误 “您没有执行此操作所需的权限” 尝试使用VBA将文件上载到QC中的测试用例时 Set QCConnection = CreateObject("TDApiOle80.TDConnection") QCConnection.InitConnectionEx QCurl QCConnection.Login qcID, qcPWD QCConnection.Connect qcDomain, qcProject Dim
“您没有执行此操作所需的权限” 尝试使用VBA将文件上载到QC中的测试用例时
Set QCConnection = CreateObject("TDApiOle80.TDConnection")
QCConnection.InitConnectionEx QCurl
QCConnection.Login qcID, qcPWD
QCConnection.Connect qcDomain, qcProject
Dim runName, sCount, TestSetParent, TestSetCount, ActualMessage, attachFactory
nPath = "Test Lab Path"
Set TSetFact = QCConnection.TestSetFactory
Set tsTreeMgr = QCConnection.TestSetTreeManager
Set tsFolder = tsTreeMgr.NodeByPath(nPath)
Set tslist = tsFolder.FindTestSets("Test Set Name")
i = 1
j = 1
Set theTestSet = tslist.Item(i)
For Each testsetfound In tslist
Set tsFolder = testsetfound.TestSetFolder
Set TSTestFactory = testsetfound.TSTestFactory
Set tsTestList = TSTestFactory.NewList("")
k = 1
For Each tstItem In tsTestList
If Not IsEmpty(tstItem) Then
runName = tstItem.RunFactory.UniqueRunName
Set RunF = tstItem.RunFactory
Set theRun = RunF.AddItem(runName)
theRun.Name = runName
theRun.Status = "Passed"
theRun.CopyDesignSteps
theRun.Post
End If
Set runStepF = theRun.StepFactory
Set aTestStepArray = runStepF.NewList("")
step_cnt = aTestStepArray.Count
For j = 1 To step_cnt ' Loop through steps and update in qc
Set runStep = aTestStepArray.Item(j)
step_QC = runStep.Name
runStep.Field("ST_ACTUAL") = runStep.Field("ST_EXPECTED")
runStep.Status = "Passed"
runStep.Post
k = k + 1
Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set Inputfolder = fso.GetFolder("FilePath")
Set Infiles = Inputfolder.Files
For Each InFile In Infiles
Set attachFactory = theRun.Attachments
Set attachment = attachFactory.AddItem(Null)
attachment.Filename = "Filename"
attachment.Type = 1
attachment.Post
theRun.Refresh
theRun.Post
Set attachFactory = Nothing
Next
Next
Next
错误发生在队列中
attachment.Post
可能需要什么权限?这是我为将附件上载到质量中心所做的修复
Set attachFactory = theRun.Attachments
Set attachment = attachFactory.AddItem(Null)
attachment.Filename = "Filename"
attachment.Type = 1
attachment.Save ' <------changed the method to save instead of post for upload in QC
Set attachFactory=theRun.Attachments
设置attachment=attachFactory.AddItem(空)
附件.Filename=“Filename”
附件.类型=1
attachment.Save“什么类型的附件<代码>附件
,为什么相关?附件是一个.docx文件。删除了excel标记,这不是问题所在。附件
是一些对象变量,您的代码没有显示任何涉及的变量的声明,因此我们只能猜测是什么。大概我们没有在查找在Outlook.mailtime
中使用ng?中定义的Post
方法是什么类型/类?它是自定义VBA类吗?是否验证了您的权限?“您没有所需的权限?”“看起来很明显是权限错误,而不是代码错误。是的,我只得到了权限的运行时错误。但我不确定需要什么样的权限。通常这意味着您的Windows登录用户对“文件路径”
所代表的内容具有读/写权限。