getObject excel - Not working properly

Hello,

 

I am attempting to create a script in which an excel file is downloaded/opened via the browser. The script completes that part easily, however I then need to grab values from the excel file and this is where I am having a problem. I have tried every variant of CreateObject and GetObject I could think of and have run out of ideas on what I am doing wrong.

 

Code as of now:

 

Set objExcel = getObject("", "Excel.Application")
Set objExcelwb = objExcel.ActiveWorkbook
Set objExcelsh = objExcelwb.ActiveSheet

intexcel = objExcel.Cells( 2, 8 ).Value

 

 

 

I have tried objExcelwb and objExcelsh at different points in time on the .Cells call.

 

I get one of a few errors depending on what I have tried. Either:

 

on the "getobject" line - ActiveX cannot create the object

on the "set objExcelsh" line - Object Required

on the "intexcel =" line - General Runtime Error //or// Object Required

 

I do have a 5 second wait before the GetObject call to make sure the excel file is fully open before hand.

 

Also, the "intexcel" line is part of a Sub that is at the top of the script. GetObject is called in main and the Sub is called after that.

 

Thanks for your time.

Parents
  • The excel which I try to access is opened by UFT and so the UFT is not able to get the object for the first time. It is working,

    1. when we give retry in the error popup (which is a manual intervention)

     

    WorkAround:

    Set objXl = createobject("excel.application")

    'create an excel process. Don't give this line until your UFT code opens the excel which you want to access. If you give after the below line, the get objects will get you empty excel objects with no active workbook since it is accessing the latest excel.

    JavaWindow("jWindow).JavaTable("jTable").DoubleClickCell r,0

    'The excel is opened in this step from the java application. You have to give your code which opens the excel.

    Execute "Set objWorkBook = GetObject(,""Excel.Application"")" 'Since the last excel is opened by UFT. It will access the required excel. The activex component issue is resolved since we created an excel process before getting the excel objects.

Reply
  • The excel which I try to access is opened by UFT and so the UFT is not able to get the object for the first time. It is working,

    1. when we give retry in the error popup (which is a manual intervention)

     

    WorkAround:

    Set objXl = createobject("excel.application")

    'create an excel process. Don't give this line until your UFT code opens the excel which you want to access. If you give after the below line, the get objects will get you empty excel objects with no active workbook since it is accessing the latest excel.

    JavaWindow("jWindow).JavaTable("jTable").DoubleClickCell r,0

    'The excel is opened in this step from the java application. You have to give your code which opens the excel.

    Execute "Set objWorkBook = GetObject(,""Excel.Application"")" 'Since the last excel is opened by UFT. It will access the required excel. The activex component issue is resolved since we created an excel process before getting the excel objects.

Children
No Data