Unable to Import XML File from QC Attachment
I'can import Excel Files from QC using the below code, but when i tried for XML Files, i got FIle Not found,
While debugging i found that,
Original File name is : MyXMLFile.xml
But QC Gets the attachment name as : ALL_LIST_26517_MyXMLFile.xml
That is the reason it says file not found.
This is the Code, I'm Using QTP 9.2 & QC 9.2
Please give your solutions,
Thanks in advance
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set tdc =QCUtil.QCConnection
set tm = tdc.TreeManager
Set folder = tm.nodebypath(Src)
Set fact = folder.Attachments
Set alist = fact.NewList("")
For Each att In alist
Set ext = att.AttachmentStorage
attname = att.DirectLink
If InStr(attname, FN) > 0 Then
ext.Load attname, True
fso.CopyFile ext.ClientPath & "\" & attname, Dest & FN
RP "The File ["&FN&"] is extracted to Local Folder","The File ["&FN&"] is extracted and placed in Local folder for importing to QTP"
RF "The File ["&FN&"] is not found in the mentioned Folder","The File ["&FN&"] is not found in folder for importing"
Re: Unable to Import XML File from QC Attachment
try the code below, it will download the attachment from a specified folder and give you back the complete path and filename, the code will work for a FOLDER ATTACHMENT
Public Function a_ext_get_FolderAttachment(TDAttachmentName, TDFolderPath)
Set otaTreeManager = QCUtil.TDConnection.TreeManager
Set otaSysTreeNode = otaTreeManager.NodeByPath(TDFolderPath)
Set otaAttachmentFactory = otaSysTreeNode.Attachments
Set otaAttachmentFilter = otaAttachmentFactory.Filter
otaAttachmentFilter.Filter("CR_REFERENCE") = "'ALL_LISTS_" & otaSysTreeNode.NodeID & "_" & TDAttachmentName & "'"
Set otaAttachmentList = otaAttachmentFilter.NewList
If otaAttachmentList.Count > 0 Then
Set otaAttachment = otaAttachmentList.Item(1)
otaAttachment.Load True, ""
strPath = otaAttachment.FileName
a_ext_reportevent micFail, "Failure in library function 'a_ext_getFolderAttachmentPath'", _
"Failed to find attachment '" & TDAttachmentName & "' in folder '" & TDFolderPath & "'."
a_ext_get_FolderAttachment = strPath
de omnibus dubitandum
For all Questions: Please be sure to take a look at the QTP Manual before posting any Questions, thanks for doing this