UFT - Excel Add-In fails to install after CreateObject is used to launch Excel

2

I am automating an Excel Plugin through UFT. I launch excel using CreateObject as:

Set oExcel = CreateObject("Excel.Application")
oExcel.Workbooks.Add
oExcel.Visible = True

Before proceeding, I want to make sure my add-in is correctly installed. So I do this:

For K = 1 To oExcel.AddIns.Count Step 1     
        If Trim(oExcel.AddIns.Item(K).Name) = "AddInName.xll" Then      
            If oExcel.AddIns.Item(K).Installed Then         
                oExcel.AddIns.Item(K).Installed = False             
                wait (2)                
                oExcel.AddIns.Item(K).Installed = True
                wait (2)                
                If oExcel.AddIns.Item(K).IsOpen Then                    
                    'Reporter.ReportEvent micPass, "Add_In Successful", "Successfully loaded Add_In"            
                    Exit For
                End If                          
            End If      
        End If
    Next    

Now this has been working without any issues in Window 7 + Office 2010 configuration. However, my firm recently moved to Windows 10 + Office 2016 environment and following line started throwing error now:

oExcel.AddIns.Item(K).Installed = True

the line before that (setting installed state to false) works fine. The error being thrown is:

The Ribbon/COM add-in helper required by add-in <> could not be registered. This is an unexpected error. ExcelDna.Integration Information: 4 : LoadComAddIn exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException: Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))

Things that I have tried:

  1. I saved the above code as a vbs file in windows 10 machine and tried to execute it. It works perfectly fine.
  2. I tried to launch excel as excel.exe instead of CreateObject. The add-in loads perfectly fine.
  3. I tried opening Excel before starting the test and used GetObject to get Excel object. The Add-In loads perfectly fine in that case.

So what's happening with CreateObject within UFT? Clearly it's UFT which is causing problem since it works fine through standalone VBS file!!

Any Help is greatly appreciated.. Thank you!!!

excel
excel-vba
vbscript
qtp
hp-uft
vba
asked on Stack Overflow Mar 31, 2017 by Sandy123456 • edited Jul 9, 2018 by Community

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0