Look in to the below code for your understanding:
Function DeleteTestResources() a=msgbox("Hello user, Do you want to delete ? " ,3, "DELETE Test Resources") Select Case a Case "6" strRetVe = "Yes" Case "7" strRetVe = "No" Case "2" strRetVe = "Cancel" End Select Select Case strRetVe Case "Yes" 'Delete Resources from selected folder strFolderName = ResourceFolder_Fields.Field("RFO_NAME").Value msgbox strFolderName msgbox Resource_Fields.Field("RSC_NAME").Value Set resourceFolderFactory = TDConnection.QCResourceFolderFactory Set folders = resourceFolderFactory.NewList("") For Each item in folders If item.Name="TestResources" Then resourceFolderId = item.ID Exit For End If Next msgbox resourceFolderId Set resourceFolder = resourceFolderFactory.Item(resourceFolderId) For iterator = 1 To resourceFolder.Count If resourceFolder.Child(iterator).Name = strFolderName Then Set resourceFactory = resourceFolder.Child(iterator).QCResourceFactory Set currResourceList = resourceFactory.NewList("") 'set RFF = TDConnection.QCResourceFactory set RFF = TDConnection.QCResourceFactory For Each item in currResourceList 'If item.Name=strTestResourceName Then strNodeID = item.ID RFF.RemoveItem(Cstr(strNodeID)) ' Exit For 'End If Next ' If Err.Number = 0 Then ' reporter.ReportEvent micPass,"Test Resource Deleted - for Post RUN","Test Resource:'"&strTestResourceName&"' Deleted successfully under folder:'"&strFolderName&"'" ' End If Exit For End If Next Set TDConnection = Nothing Set RFF = Nothing set resourceFolderFactory = Nothing Set resourceFolder = Nothing Set resourceFactory = Nothing Set currResourceList = Nothing Case "No" Exit Function Case "Cancel" Exit Function End Select End Function
Am getting Folder Name, File Name ....but unable to delete the file. Help me on this code or any suggestions to modify the code. (Am not getting resourceFolderId) But if we execute the same in QTP/UFT it is working.