Hi,
U can use this,
Code:
Function ImportDataSheet(strsheet)
Dim sheet_name
sheet_name=DataTable.LocalSheet.Name
Call Import_ressources("Subject\97_RTT Resources","TestData","DataSheet.xls",strsheet,sheet_name)
End Function
Subject\97_RTT Resources---> Path in QC
TestData---> Folder in QC where Data sheet is stored
DataSheet.xls----> .xls file(datasheet)
strsheet---> worksheet within .xls workbook from where u want to import data.
sheet_name----> Datatable in qtp where u want to import the .xls file
Code:
Function Import_ressources (parent_folder, proj_name, src_file, src_sheet, dest_sheet)
Import_ressources = false
Set objTreeManager = QCUtil.TDConnection.TreeManager
Set projNode = objTreeManager.NodeByPath(parent_folder)
' projNode.Count = nombre de REPs trouvés
For i = 1 to projNode.Count
' Le sous_dossier a été trouvé
If instr (1, projNode.Child(i).Name, proj_name) > 0 Then
Set projNode = projNode.Child(i)
Exit For
End If
Next
wait(2)
' Recherche du fichier paramètres (attaché)
Set res = projNode.Attachments.NewList("")
For Each attach In res
If Not Instr(1 , attach.FileName , src_file) = 0 Then
attach.Load True, "C:\"
datatable.AddSheet (dest_sheet )
' REM : 1 --> première feuille dans le fichier XLS
DataTable.ImportSheet attach.FileName, src_sheet, dest_sheet
'DataTable.ImportSheet attach.FileName, 1, dest_sheet
Import_ressources = true
End If
Next
wait(2)
End Function
Regards,
Sankalp