how can I get the Name or index of 'dtLocalSheet'?
This doesn't work:
DataTable.ExportSheet "C:\test.xls", dtLocalSheet
whereas this does...
DataTable.ExportSheet "C:\test.xls", "Action1"
So how can I access this local sheet?
Any advice or hints are welcome.
The index depends on the occurence of the Sheet.
Suppose ur script has, "Global", "Action1", and "Action2" sheets in that order,
Global will have an Index of 1
Action1 = 2
Action2 = 3
So, DataTable.ExportSheet "C:\test.xls", 2
Here is small function to find out sheetname using sheet index in the current QTP script
Function GetSheetName (SheetIndex)
Set OApp = CreateObject("Excel.Application")
CurTestPath = Environment("TestDir")
Set objActiveWkb = OApp.ActiveWorkbook
cnt = objActiveWkb.Worksheets.Count
if (SheetIndex > cnt)then
GetSheetName = ""
GetSheetName = objActiveWkb.Worksheets(SheetIndex).Name
Thank you for your input, but your solutions
don't really address, what I meant.
Maybe I described my question in a wrong way.
What I need is to find out the index or the name
of the current Local sheet, because I would like
to do exactly what brainZ showed
(DataTable.ExportSheet "C:\test.xls", 2)
only that I would like to pass the number (2)
as a variant from the index of the local sheet,
intIndex = dtLocalSheet.index
DataTable.ExportSheet "C:\test.xls", intIndex
unfortunately this doens't work, as I get an Index value of 1001 for the dtLocalSheet...
Same would happen, if I would use dtLocalSheet.name
So I need an alternative way to get the index or name...
I believe the approach of SatyaTota
could work, but I guess I'll have to adapt it to get this index value of dtLocalSheet...
Is the default.xls file a runtime copy of the
current Data Table?
If you have any more input I would be very grateful.