Thursday, June 3, 2010

QTP KB 2 - General Error when export/Import Datatable

QTP's famed datatable is third party control similar to excel, many confuse its extension when compared to MS-Excel and implement various formatting features into the excel file, which would be imported during script run.

Since the datatable is not a excel control, there is a high percent chance of corruption, when that happens, the dreaded "General Run Error" is thrown"

Easiest way to workaround is to clear the data in the parent file, and create new one.

Noted below is the HP-Mercury KB article and detailed steps for the same

Issue 1: Exporting runtime datasheet to localpath.(Export error no:"-214746725 9")

During runtime, when we try to export the datasheet to local folder we get a general runtime error. So every time we have to kill the QTP and its process tree to proceed.
Solution: Whenever we get ‘General Run Error’ while exporting, clean up the excel sheets as mentioned below and proceed with execution:
How to clean up all Excel formatting from XLS file using QuickTest Professional (QTP)
Making use of the internal logic/functionality offered within QTP, it is possible to clean up Excel format from a XLS file by using either of following methods. By using any of the following methods a new XLS file will result with lower file size once Excel formatting gets removed:
• Using QTP's user interface
1. Open QuickTest Professional and a new blank test script
2. Access the File menu, then select "Settings"
3. Go to the "Resources" tab
4. Under the "Data Table" field, select "Other location" option and click on the browse button ("...")
5. Once the "Open Data Table" dialog appears, find and select the XLS file desired to clean format and click "Open"
6. Click on "Apply" then "Ok" to close dialogs accepting changes Note: depending on the clean up done by QTP, processing time to later show data on the Data Table pane may vary depending on XLS file size and content
7. On the Data Table pane, right click and under "File" option, select "Export..."
8. Select a location/path and name to save this new version of XLS file
• Using VBScript and QTP Automation Object Model (AOM)
Note: The following script is provided for example purposes only. It is not supported by Hewlett Packard.
filepath = "C:\MyExcelFile.xls"

Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set procList = objWMI.ExecQuery("Select * from Win32_Process " & _
"Where Name = 'QTPro.exe' " & _
"Or Name = 'QTAutomationAgent.exe'")
alreadyOpen = false
For Each objProcess in procList
Select Case UCase(objProcess.Name)
alreadyOpen = true
End Select
Set procList = Nothing
Set objWMI = Nothing
On Error Resume Next
Set App = CreateObject("QuickTest.Application")
If Err.Number <> 0 Then
MsgBox "Error Instancing QuickTest.Application class. Assure QTP is installed on machine"
If Not alreadyOpen Then App.Launch
App.New False
App.Test.Settings.Resources.DataTablePath = filepath
Dim aux, filename
aux = Split(filepath, "\")
filename = Split(aux(UBound(aux)), ".")
tempname = filename(UBound(filename)-1) & "_BAK." & filename(UBound(filename))
tempname = Replace(filepath, aux(UBound(aux)), tempname)
App.Test.DataTable.Export tempname
App.Test.Settings.Resources.DataTablePath = ""
Set fso = CreateObject("scripting.filesystemobject")
fso.DeleteFile filepath
fso.MoveFile tempname , filepath
App.New False
If Not alreadyOpen Then App.Quit
End If
Set App = Nothing


Any issue with the above code, reach out to HP-Mercury :)

** Happy Automating **


Ravi Kumar Gajul said...

That was a great info really helped
Thankyou so much

Anonymous said...

Εxcellent blog уou have here but І was cuгіous іf you κnew of any message boаrds that cover the sаme tοpics talked abοut in
thіs artіcle? I'd really like to be a part of community where I can get feed-back from other knowledgeable individuals that share the same interest. If you have any suggestions, please let me know. Thanks a lot!
Also see my site: savior

Anonymous said...

If some one desires to be updated with most recent technologies therefore he must be go to see this web page and be up to date daily.

My web blog: acheter vue youtube

Anonymous said...

Howdy! Someone in my Myspace group shared this website with us so I came to take a look.

I'm definitely enjoying the information. I'm bookmarking
and will be tweeting this to my followers! Great blog and brilliant
design and style.

Feel free to visit my blog post :: acheter tweet

Anonymous said...

Нi thеre, this weеκеnd iѕ gοоd
foг me, becаuse thiѕ ρoint in time i
am reaԁіng this imprеѕsive informаtіνе ρoѕt hеre
at my home.

Take a look аt my web site :: buy omega 3

Anonymous said...

Howdy! I know this is kinda off topic however , I'd figured I'd ask.
Would you be interested in trading links or maybe guest authoring a blog article or vice-versa?
My blog goes over a lot of the same topics as yours and I think
we could greatly benefit from each other. If you're interested feel free to send me an e-mail. I look forward to hearing from you! Superb blog by the way!

Take a look at my blog ... Marketing promotions strategy

Anonymous said...

Terrific article! That is the kind of info that are
supposed to be shared around the net. Disgrace on Google for no longer positioning this put
up upper! Come on over and consult with my website . Thanks =)

Feel free to surf to my site;