preload

How to use test data from a locked Excel Workbook (QTP, VBScript)

Posted by Albert Gareev on Apr 08, 2010 | Categories: How toMS Excel Data

Parent page: Service Functions – Excel (QTP, VBScript)

Question

The question was asked here.

How can I get data from Excel spreadsheet if it is accidentally open? It ruins whole batch execution.
While opening manually I can go “read-only” and still access it.
Is there any way to read data from an open and locked Excel file from QTP?

Answer

You can programmatically open an Excel workbook and check whether it’s accessible as read-only.

If you need to get a full control of Excel data files during a batch execution of scripts I suggest the following logic.

Description

1. Check if Excel Workbook is locked

2. Create a duplicate file

3. Use duplicated file as a data source

4. Delete when you no longer need it


  • One response to "How to use test data from a locked Excel Workbook (QTP, VBScript)"

  • Chen R.
    9th April 2010 at 0:45

    Great information! I’ve been looking for something like this for a while now. Thanks!

Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported
This work by Albert Gareev is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported.