Mapping Excel col names (QTP, VBScript)

Posted by Albert Gareev on May 23, 2009 | Categories: How toMS Excel Data

Original date: 5 Dec 2008, 1:23pm

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

'Excel file exists
'Workbook is open (XLBook)
'Sheet exists
Set objUsedRange = XLBook.Worksheets(sSheetIndex).UsedRange()

Set objSheetColNameMap = CreateObject("Scripting.Dictionary")
For Iter = 1 To objUsedRange.Columns.Count
   sCellText = objUsedRange.Cells(1,Iter)
   If sCellText <> "" Then
      objSheetColNameMap.Item(sCellText) = Iter
   End If

  • One response to "Mapping Excel col names (QTP, VBScript)"

  • Lena
    6th April 2010 at 7:52

    Hi Albert,

    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?


    [ Albert’s reply: here’s the example. ]

  • Leave a Reply

    * Required
    ** Your Email is never shared

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.