Commander Commander
Commander
286 views

Error #1004 during test set export

We've added a function to QC to export test set data to Excel from the Test Lab.  This function has been working flawlessly in the past, but today a user reported an error.  When using the export function, they get the error:

Error #1004: a workbook must contain at least one visible worksheet.  To hide, delete, or move the selected sheet(s) you must first inser a new sheet or unhide a sheet that is already hidden.

The native export functions (such as exporting defect data to Excel) seem to work fine.

Has anyone seen this error before? So far Google hasn't revealed anything helpful...

TIA for any suggestions

0 Likes
2 Replies
Vice Admiral Vice Admiral
Vice Admiral

"Added a function to QC" - as in workflow? how is this implemented? Are you able to post code?

0 Likes
Commander Commander
Commander

Yep, we've done this via workflow scripting.  Here's the code:

Function FTI_TestSet_ExportAll
'on error Resume next

dim objTestSF
dim ListsofTestSets
dim TS, TnTS, step
dim objFolder
dim objTSTest
dim objTestsinTS
dim objRuns
dim runs
dim stTestSet
dim objStep
dim SFList
dim intRuns


'Create test set factory object and Filter on current folder
set objTestSF=TDConnection.testsetfactory.filter
'filter on the selected folder
objTestSF.Filter("CY_FOLDER_ID")=CURRENTFOLDER
'create list of test sets in selected folder
set ListsofTestSets=objTestSF.newlist()

'Create Excel object and make it visible
FTI_EXPORT_BEGINWK()

' If there are no test sets under the folder, export string stating such
if ListsofTestSets.count=0 then
stTestSet="No Test Sets Exist"
FTI_EXPORT_BEGINSHEET stTestSet
FTI_EXPORT_SETCOL(1)
FTI_EXPORT_NEXTHEADER("Test Set")
FTI_EXPORT_NEXTFIELD stTestSet, False
FTI_EXPORT_NEXTROW()
FTI_EXPORT_SETCOL(1)
FTI_EXPORT_NEXTHEADER("TS Tree Path")
FTI_EXPORT_NEXTFIELD CURRENTFOLDER, False
end if

' for each testset
For each TS in ListsofTestSets

'capture full path of testset when exporting
set objFolder=ts.field("CY_FOLDER_ID")
CURRENTFOLDER="^" & objFolder.Path & "^"

'Name the worksheet the same as the testset
FTI_EXPORT_BEGINSHEET(TS.field("CY_CYCLE"))

' format the worksheet columns
FTI_EXPORT_FORMATCOLS 1,1,14
FTI_EXPORT_FORMATCOLS 2,2,5
FTI_EXPORT_FORMATCOLS 3,3,8
FTI_EXPORT_FORMATCOLS 4,5,12
FTI_EXPORT_FORMATCOLS 6,8,18
FTI_EXPORT_FORMATCOLS 9,9,16
FTI_EXPORT_FORMATCOLS 10,16,15
FTI_EXPORT_FORMATCOLS 16,16,11

'Export Test set path and description
FTI_EXPORT_SETCOL(1)
FTI_EXPORT_NEXTHEADER("Test Set")
FTI_EXPORT_NEXTFIELD TS.field("CY_CYCLE"), False
FTI_EXPORT_NEXTROW()
FTI_EXPORT_SETCOL(1)
FTI_EXPORT_NEXTHEADER("TS Tree Path")
FTI_EXPORT_NEXTFIELD CURRENTFOLDER, False
FTI_EXPORT_NEXTROW()
FTI_EXPORT_SETCOL(1)
FTI_EXPORT_NEXTHEADER("TS Description")
FTI_EXPORT_NEXTFIELD ts.Field("CY_COMMENT"), False
FTI_EXPORT_NEXTROW()

'create list of tests in the test set
set objTSTest=TS.TSTestFactory
set objTestsinTS = objTSTest.newlist("")

' for each test in the test set...
for each TnTS in objTestsinTS

'Export Headers for Tests in Testsets
FTI_EXPORT_SETCOL(3)
FTI_EXPORT_NEXTHEADER("Test_ID")
FTI_EXPORT_NEXTHEADER("Test_Name")
FTI_EXPORT_NEXTHEADER("Test Status")
FTI_EXPORT_NEXTHEADER("Responsible Tester")
FTI_EXPORT_NEXTHEADER("Planned Execution")
FTI_EXPORT_NEXTHEADER("Actual Tester")
FTI_EXPORT_NEXTHEADER("Actual Execution")
FTI_EXPORT_NEXTHEADER("Last Run Name")

'Export Headers for Last Test Run
FTI_EXPORT_SETCOL(11)
FTI_EXPORT_NEXTHEADER("Step Name")
FTI_EXPORT_NEXTHEADER("Execution Date")
FTI_EXPORT_NEXTHEADER("Description")
FTI_EXPORT_NEXTHEADER("Expected Result")
FTI_EXPORT_NEXTHEADER("Actual Result")
FTI_EXPORT_NEXTHEADER("Step Status")
FTI_EXPORT_NEXTROW()

'export test data
FTI_EXPORT_SETCOL(3)
FTI_EXPORT_NEXTFIELD TnTS.field("TC_TEST_ID"), False
FTI_EXPORT_NEXTFIELD FTI_GetTestName(TnTS.field("TC_TEST_ID")), True
FTI_EXPORT_NEXTFIELD TnTS.field("TC_STATUS"), False
FTI_EXPORT_NEXTFIELD TnTS.field("TC_TESTER_NAME"), False
FTI_EXPORT_NEXTFIELD TnTS.field("TC_PLAN_SCHEDULING_DATE"), False
FTI_EXPORT_NEXTFIELD TnTS.field("TC_ACTUAL_TESTER"), False
FTI_EXPORT_NEXTFIELD TnTS.field("TC_EXEC_DATE"), False

'create list of runs for each test in the test set
set objRuns = TnTS.runfactory
set runs=objRuns.newList("")

'count the number of runs for the test
intRuns=runs.count
' if there are no runs
if intRuns = 0 then
'export a statement
FTI_EXPORT_SETCOL(11)
FTI_EXPORT_NEXTFIELD "This Test has not been run", False
FTI_EXPORT_NEXTROW()

'if there are runs
else
'export the name of the last run
FTI_EXPORT_NEXTFIELD TnTS.lastrun.name, TRUE

'create list of steps in the last run
set objStep= tnts.lastrun.stepfactory
set SFList=objStep.newlist("")

' for each step
for each step in SFList
with step
'export step data
FTI_EXPORT_SETCOL(11)
FTI_EXPORT_NEXTFIELD .Field("ST_STEP_NAME"), True
FTI_EXPORT_NEXTFIELD .field("ST_EXECUTION_DATE"), False
FTI_EXPORT_NEXTFIELD .field("ST_DESCRIPTION"), True
FTI_EXPORT_NEXTFIELD .field("ST_EXPECTED"), True
FTI_EXPORT_NEXTFIELD .field("ST_ACTUAL"), True
FTI_EXPORT_NEXTFIELD .field("ST_STATUS"), False
FTI_EXPORT_NEXTROW()
end with
next
end if
next
next
'cleanup the worksheets
FTI_EXPORT_END

'discard objects used in this function
set SFList = nothing
set objStep = nothing
set runs = nothing
set objRuns = nothing
set objTestsinTS = nothing
set objTSTest=nothing
set ListsofTestSets = nothing
set objTestSF = nothing

END FUNCTION

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.