Micro Focus QTP (UFT) Forums

Full Version: Not recognising my objExcel
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This has been a mystery to me. When to Set my objExcel. You can say that I am very confussed.

Currently, I create a great spreadsheet called DocViewHref. I save the file then I want to use the data in my spreadsheet.

I am however getting a Run Error while accessing my data.

Object required: 'objExcel'
Function file: O:\QTP Tests\LibraryImageAccessTests-2.qfl
Line (151): " ReportType = objExcel.Cells(r,3).Value"

...
Code:
' START NEW FUNCTION FOR VIEW, ZIP, FAX AND OTHER (DOCVIEW)
Dim objExcel, objFso

Call KillExcel
Call KillPDF

Call CountNumberofDocViewsLinksHrefs (objExcel, rNumber) 'Create Excel Spreedsheet

'Set objExcel = CreateObject("Excel.application") 'Create a new Microsoft Excel object

'Keep the iterations under 20 (equates to 5 DocTypes)
If rNumber > 21 Then
    rNumber = 21
End If

For r = 2 to rNumber ' loop thru your DocView values (from 2 to rNumber or set to #)
        'DocView
        ReportType = objExcel.Cells(r,3).Value
        'abs_x location
        absX = objExcel.Cells(r,4).Value
        'abs_y location
        absY = objExcel.Cells(r,5).Value
        'Href
        Hreff = objExcel.Cells(r,6).Value
...
This use to work. Im not sure if I need to reset the objExcel or not. I do not think I do.

The Call creates and saves the spreadsheet to O:\QTP Tests\QTPOutputData\DocViewHref.xls. The spreadsheet remains open.

What do I need to do differently to access my ss?

thxx
objExcel.Cells(r,3) ??
how can you access a cell value without creating instances of workbook and worksheet
mv8167
Suggesting to make some google search before posting any new thread...