DataTable.ImportSheet operation failed.Invalid file


I'm running Excel tests on UFT and sometimes I get the error number 20012 which is "DataTable.ImportSheet operation failed.Invalid file".

This is my way of importing the script:

DataTable.ImportSheet filepath,scriptname,"Action2" <ul><li>

filepath is the path of my workbook which conatins many excel sheets (scripts)

</li> <li>

scriptname: the name of the script that I want to run

</li> <li>

Action2: contains all the call of all possible keywords that may script can contains.

</li> </ul>

Any help please, why I'm getting this error.

The problem is that this is working well for some scripts and for others not after 3 or 4 run times.

I think the problem is on Excel itself and not on the code, are there any problems when working with Excel 2016 and UFT 12 ?


UFT syntax for importing a worksheet is:

DataTable.ImportSheet FileName, vtSrcSheet, vtDstSheet

This means you need to pass as parameters the filename (and path) to the excel file, the name (or index) of the source sheet you want to import, and then the destination you want this sheet to be (for example "Global" or "Action1" etc)

Unless scriptname happens to be the exact name of the worksheet you are trying to import you will get this error.

If you want to import the whole file use Datatable.Import instead of Datatable.ImportSheet


  • SQL Server - Compare 2 tables for data in the same columns without checking for equality
  • A “regex for words” (semantic replacement) - any example syntax and libraries?
  • counting only truthy values in a collection [duplicate]
  • what is the advantage of using Alamofire over NSURLSession/NSURLConnection for networking?
  • Assigning variable and using it in range
  • Outlook.Store.GetDefaultFolder Outlook is creating strange folders in a new .pst file
  • Getting Spring 4 dependency injection working with RESTeasy 3 validator
  • Post method on Angular 5. No error but it doesn't work
  • Select Checkbox !== Select Row Table
  • Preventing Internet-accessing-method from delaying a toast popup
  • WSO2 Identity Server + Rest STS Client (without ESB)
  • Force fading edge on TextView
  • How can i use JQuery fadeTo() in IE 7?
  • python socket.sendto
  • Use PHP to Replace HTML with HTML
  • How to get the Owner of the ContextMenu (from Silverlight 4 toolkit)?
  • Scripting Support For Image Filtering in DigitalMicrograph
  • Javascript inside HTML import not affecting imported HTML
  • C# code can't “see” the methods in my C++ dll
  • Building JavaFX 2.0 App on Mac, deploying on Windows
  • Copy and paste data from multiple workbooks to a worksheet in another Workbook
  • 'Edit' function for forum posts and such
  • How to join two tables from different databases
  • Swift: UIView.animate works unexpectedly
  • Add font awesome icon to custom add to cart button in Woocommerce 3
  • Create an average of multiple excel chart without the data source
  • JQuery: Infinite input select
  • how to run ejabberd with Erlang on Heroku?
  • Debug `Unexpected end of JSON input Error` on content script
  • Bad automatic Triangulation with Mayavi for coloring a surface known only by its corner
  • Python Flask - GUI for client
  • Using Service Component Runtime
  • How to handle a codeigniter PDF generator