Getting general QTP error exporting to excel (2872 Views)
Reply
Occasional Advisor
jclosa10
Posts: 6
Registered: ‎03-15-2010
Message 1 of 18 (2,872 Views)

Getting general QTP error exporting to excel

Hello,

I am using QTP 9.5 and MS Office 2007. My script run successfully, but in the very last line it fails. I am trying to export the results to excel using DataTable.ExportSheet "C:\QTPResults\executionInfo.xls","Global" and it fails!!!

the only message I get is that a general error occured and that is it. I tried to re.build my script and it doesn't work. Any clue?
Please use plain text.
Honored Contributor
Reju George
Posts: 380
Registered: ‎01-15-2009
Message 2 of 18 (2,872 Views)

Re: Getting general QTP error exporting to excel

Is your results stored in the Global data sheet ?
Also is the excel sheet already open when you are trying to execute this ?
Please use plain text.
Honored Contributor
Sperk
Posts: 933
Registered: ‎04-22-2009
Message 3 of 18 (2,872 Views)

Re: Getting general QTP error exporting to excel

Not sure if this is the issue but the file extension for Excel 2007 is .xslx

Mark Smith.
Please use plain text.
Occasional Advisor
jclosa10
Posts: 6
Registered: ‎03-15-2010
Message 4 of 18 (2,872 Views)

Re: Getting general QTP error exporting to excel

Thanks a lot for your answers. Yes, I am storing results in the Global Sheet and No, I don't have the file opened while executing the test. It is an existing file though.

It used to work for 2+ years, and all of the sudden it does not work :S

I also tried changing file extension to xlsx, but it saves the file as corrupted :S

This is the error I am getting: Runtime error: A general error occurred while exporting sheet C:\QTPResults\verifyExecutionInfo.xls to file Global

Also, one more interesting thing is that this script has calls to external actions. If I run the code without the call to these external actions, I have no problems. When adding the external actions is when I get the error.
Please use plain text.
Honored Contributor
Reju George
Posts: 380
Registered: ‎01-15-2009
Message 5 of 18 (2,872 Views)

Re: Getting general QTP error exporting to excel

Could it be that your excel sheet has so many sheets ? If the sheet "Global" does not exist in the file, then it would append it to the end. I guess Excel does not support more than 256 sheets.
Did you try running this on a totally new file ?
Please use plain text.
Occasional Advisor
jclosa10
Posts: 6
Registered: ‎03-15-2010
Message 6 of 18 (2,872 Views)

Re: Getting general QTP error exporting to excel

Yeah, I tried to re-build the script and also creating a file with different names so that it doesn't need to overwrite the existing one, but no luck.

Could it be some failure in QTP? Are there any chances that if I uninstall and re-install it gets corrected?
Please use plain text.
Honored Contributor
Reju George
Posts: 380
Registered: ‎01-15-2009
Message 7 of 18 (2,872 Views)

Re: Getting general QTP error exporting to excel

You could try reinstalling. Maybe something got corrupt within QTP. You also said that removing the calls to external actions solves your problem which is sort of wierd. So try reinstalling and all the best !!
Please use plain text.
Occasional Advisor
Suman04
Posts: 6
Registered: ‎04-06-2010
Message 8 of 18 (2,872 Views)

Re: Getting general QTP error exporting to excel

Hi jclosa10,

I am also facing the same issue from past 2 weeks, tried re-installing QTP but it was of no use.

Was this issue resolved for you?

Thanks,
Suman
Please use plain text.
Occasional Advisor
jclosa10
Posts: 6
Registered: ‎03-15-2010
Message 9 of 18 (2,872 Views)

Re: Getting general QTP error exporting to excel

Hello. No, it didn't help. As of now, I haven't been able to resolve the problem. It continues to happen some times.

I created some recovery scenarios that get fired every time a general error occurs in QTP. In the recovery scenario, I have the instruction
DataTable.ExportSheet "C:\QTPResults\executionInfo.xls","Global"

Same thing as we with the current code. Some times it works, and some others it doesn't :S

It is VERY weird
Please use plain text.
Honored Contributor
Joshua S_1
Posts: 379
Registered: ‎09-15-2008
Message 10 of 18 (2,872 Views)

Re: Getting general QTP error exporting to excel

Are there other ExportSheet calls before this line? At one point we had an issue like this, and we think it was caused because the first ExportSheet call did not truly finish before the next call started, so the file was actually still in use. That could explain why your recovery scanario sometimes works. If that is the case, you could try adding a Wait statement before your ExportSheet statement to give time for the file to be completely updated.
Please use plain text.
Occasional Advisor
Suman04
Posts: 6
Registered: ‎04-06-2010
Message 11 of 18 (2,872 Views)

Re: Getting general QTP error exporting to excel

I know its v wierd!

bcoz of this I am facing another problem;
QTP hangs if execution is terminated.
If the qtp is in execution mode and user stops the execution. Then next time user is not able to execute. The following error is displayed - "Unable to create the specified run results folder. The folder may be in use by another program. Close other program that are using this folder." The troubleshooting steps taken:
1. Even after disk clean up the problem exists.
2. We tried deleting the temp results folder but we were not able to delete file 'Default.xls'.
So every time I had to kill the QTP and its process tree to proceed.

Please use plain text.
Occasional Advisor
jclosa10
Posts: 6
Registered: ‎03-15-2010
Message 12 of 18 (2,872 Views)

Re: Getting general QTP error exporting to excel

Joshua,

I don't have any exportsheet statements previous to this one, this is the only one in the whole script.

There is something that I've been doing as a workaround, which is obviously not a solution, but it helps saving a 120 rows file, with several lines of comments in each row. This workaround consists on:
1. I add a breakpoint in the line where the excel should be exported.
2. Click F11 to get that line of code executed.
3. I go to the folder where the file should be exported. If it was created, the I resume execution. If it doesn't, then I continue debugging step by step.
4. Right after the export statement, I have the error handling for the script. If it enters the error handling, it means that the export failed.
5. What I do, is to do several actions with the runtime data table until it appeaers like it is frozen and not responding.
6. Then, I have the same export statement within the error handling statements. It gets executed and it works!!!!!

See code below


Call DataTable.ExportSheet("C:\QTPResults\verifyExecutionInfo.xls","Global")


If Err.Number <> 0 Then
Reporter.ReportEvent micWarning, "InitAction", "Runtime error: " & Err.Description
InitAction = False
Err.Clear
Call DataTable.ExportSheet("C:\QTPResults\verifyExecutionInfo.xls","Global")
ExitRun("Fail")
End If


In summary, I am thinking it is something related to the data table, but can't get to what it is.

Suman, the same exact behavior happens to me every now and then when it fails :(
Please use plain text.
Occasional Advisor
Suman04
Posts: 6
Registered: ‎04-06-2010
Message 13 of 18 (2,872 Views)

Re: Getting general QTP error exporting to excel

You could implement export functionality using Excel Objects approach.
Please use plain text.
Occasional Advisor
jclosa10
Posts: 6
Registered: ‎03-15-2010
Message 14 of 18 (2,872 Views)

Re: Getting general QTP error exporting to excel

Hello Suman,

I don't have experience with this. Can you ellaborate a little bit more? Do you have some sample lines of code?

Thanks!
Please use plain text.
Occasional Advisor
Suman04
Posts: 6
Registered: ‎04-06-2010
Message 15 of 18 (2,872 Views)

Re: Getting general QTP error exporting to excel

Hi,

You need to first download the excel attachment from QC to local path. Then work on the sheet using excel objects. I am still working on it.

' Some sample codes on excel objects
intRow=1
Set excelObj=CreateObject"Excel.Application")
Set workBooks = excelObj.Workbooks.Open("C:\IMPORT\abc.xls")
Set workSheets = excelObj.worksheets("abc")
For Each c In workSheets.Range("A1:Z1").Cells
If c.Value = "XXX" Then
intCol = c.Column
Exit For
End If
Next
workSheets.Cells(intRow,intCol).value = "Y"
workBooks.Save
excelObj.Workbooks.Close()
Please use plain text.
Occasional Advisor
Suman04
Posts: 6
Registered: ‎04-06-2010
Message 16 of 18 (2,872 Views)

Re: Getting general QTP error exporting to excel

Refer the below link...may be useful!

http://excelvbamacro.com/
Please use plain text.
Visitor
mansoor_shaikh
Posts: 2
Registered: ‎02-08-2012
Message 17 of 18 (2,678 Views)

Re: Getting general QTP error exporting to excel

Sorry for replying to an old thread. but now, I am facing this exact issue.

ExportSheet used to work earlier several times, Now, all of a sudden, without any code change, this statement is failing with the same General error as mentioned.

 

Did anyone managed to get a fix for this problem. If yes, can you please share the fix for it.

 

Thanks,

Mansoor

Please use plain text.
Visitor
mansoor_shaikh
Posts: 2
Registered: ‎02-08-2012
Message 18 of 18 (2,677 Views)

Re: Getting general QTP error exporting to excel

Please Note:

I am using QTP 11 on a windows xp machine.

Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation