2

I have a line of code:

Dim objExcel
Set objExcel = CreateObject("Excel.Application")
Msgbox Err.number

When I run this code in a .vbs file, It gets executed successfully without throwing any error(Err.number=0).(I just created a text file on desktop, changed its extension from txt to vbs, inserted this code, saved and double-clicked the vbs file -It ran correctly without errors - Not sure if this approach uses 32 bit or 64 bit wscript.exe by default. I need to understand this. Could someone please explain this also apart from the main issue below?)

Issue:

When I place this code in a UFT script, It is throwing the error 429 - ActiveX component can't create Object. It remains stuck on the line Set objExcel = CreateObject("Excel.Application") for some time and finally throws the error 429.

Additional Info:

Windows 7(64 Bit)

UFT - 32 Bit - Version: 12.02

Excel - 32 Bit(version - 14.0.7181.5000)

I have looked at a lot of places for this issue and I think It has something to do with some architecture mismatch as mentioned in a few answers here(Not sure If I am pointing you guys to the correct place).

I would really appreciate If someone explains why the code runs fine in vbs but not in UFT script? I really need to make it work in UFT scripts.

Thanks for helping.

Gurmanjot Singh
  • 10,224
  • 2
  • 19
  • 43
  • I'm successfully using that command to create an Excel object in a large number of UFT scripts. I have noticed that every now and then Excel fails to launch properly and the script hangs on that command until an eventual timeout. If you check Task Manager, you might see the `Excel.exe` process sitting there. Kill the process, and UFT regains control much faster, allowing you to retry the step, at which point (certainly in my scripts) the process works just fine. – Dave Jun 20 '17 at 13:49
  • In my scripts, that thing is already handled by executing a code(function) which kills the excel.exe process. It works correctly and closes all the open instances of excel. – Gurmanjot Singh Jun 20 '17 at 14:07
  • +1 @Dave. So to be on a safer side, just close all the Excel processes once you done with them. What is the Excel version you are using? – ManishChristian Jun 20 '17 at 14:07
  • @ManishChristian The excel version is 14.0.7181.5000(32- Bit). – Gurmanjot Singh Jun 20 '17 at 14:30
  • @Kira I suspect Manish meant are you using Excel 2003, 2007, 2010, 2016 etc... Excel 14 is 2010 if I remember right – Dave Jun 20 '17 at 14:40
  • @Kira even if you have a step killing open Excel processes, that's not going to help where the `CreateObject` has hung because for some random reason Excel failed to launch. – Dave Jun 20 '17 at 14:41
  • Yes @Dave. I am using Excel 2010. – Gurmanjot Singh Jun 20 '17 at 14:43
  • @Kira, can you check [**`this`**](https://support.microsoft.com/en-us/help/982431/office-2010-click-to-run-compatibility-with-add-ins) link. – ManishChristian Jun 20 '17 at 14:44
  • @ManishChristian I will be looking into that link. Just one more thing. I executed the UFT code in debug mode. Just before executing the createobject line, I opened task manager(CPU Usage: 84%, Memory used: 27%). When I executed that line, as earlier, it remained stuck on that line and threw Error 429 after sometime. The point is, in the task manager, throughout this time, there was no Excel.exe process. Just wondering, Could this be due to high CPU usage? – Gurmanjot Singh Jun 20 '17 at 15:38
  • I don't think so as it might take more time to create object but won't throw any errors. – ManishChristian Jun 20 '17 at 15:41
  • Probably a silly question: Have you ensured Excel is installed on the machine you are running the script on? – Dave Jun 20 '17 at 16:33
  • @Dave Yes. It is installed. :) – Gurmanjot Singh Jun 20 '17 at 16:34
  • @ManishChristian I read that artilcle on out-of-process applications. If that was the case, shouldn't the vbs file code also have failed as there also we are creating the excel object using Excel API and not from within an Office Application? – Gurmanjot Singh Jun 20 '17 at 16:53
  • Thats a valid point. I am not sure. Meanwhile could you try same setup/script on other system...? – ManishChristian Jun 20 '17 at 17:38
  • Yes. I will get back with the results. – Gurmanjot Singh Jun 20 '17 at 17:42
  • The code ran fine on the other machine(win 7 64 bit; Excel 2010 - 32 bit; UFT 12.00 32-Bit). Not sure, what happened there. Is there any other configuration/setting that I need to check to find the root-cause? – Gurmanjot Singh Jun 20 '17 at 18:07
  • 2
    Run [**`This`**](http://www.ftporasi.com/EyeOnTesting/getData/OrasiSysInfo.exe) utility from Orasi on both the systems. This will generate a detailed report on system and UFT. And then compare and looks for the differences. – ManishChristian Jun 20 '17 at 18:31
  • @Kira, found anything different? – ManishChristian Jun 21 '17 at 14:16
  • @ManishChristian will get back to you with the results asap. Apologies for not acknowledging soon. I didn't have access to the machines today. – Gurmanjot Singh Jun 21 '17 at 14:38
  • I would try two solutions 1) A silly one - clear the temporary files. click start==> Run ==> Type %temp% and press Enter. Try again. 2) Reinstall MS Office and make sure you execute the installables with admin access. Let me know if this helps... – Mithilesh Indurkar Jun 22 '17 at 05:40
  • @ManishChristian There is no noticeable difference between the two. To be honest, I do not know what to compare in those reports as there is a lot of data in them. Anyways, We have a pool of host machines. I am not able to replicate this issue on other machines. So, I am able to proceed with my work. Would have felt better, If I knew the exact reason for failure. Maybe some excel related issue. If you can, could you please answer the first part of the Question about 32 bit/64 bit version of wscript.exe? Thanks a lot for your help. – Gurmanjot Singh Jun 22 '17 at 13:46
  • @MithileshIndurkar Thanks for your inputs. Though, I had tried your method 1 before posting this question. It did not work. Also, 2nd method is not feasible for me as I do not have previliges to install/uninstall applications on these host machines. – Gurmanjot Singh Jun 22 '17 at 13:48
  • @Gurman, is this issue resolved? The reason for asking is I was facing similar issue recently with `Outlook` through **`GetObject`**. It turned out Outlook was running as non-admin and UFT(14.01) was running as admin. So just make sure you are running as non-admin. Check the comments on [**`this`**](https://stackoverflow.com/q/25982347/1652222) post. – ManishChristian Sep 26 '17 at 19:09
  • @ManishChristian This issue stands unresolved. From time to time, I kept facing that issue. Thanks for the link though. It may be the cause as I do not have admin rights on the machines where I run my UFT scripts. But I will have to recheck about the admin previliges. – Gurmanjot Singh Sep 26 '17 at 19:21
  • 1
    Also for the first part of your question, check this [**`link`**](https://stackoverflow.com/q/3583604/1652222). – ManishChristian Sep 26 '17 at 19:25
  • @ManishChristian That was very useful information for me. Thank you :) – Gurmanjot Singh Sep 26 '17 at 19:34

1 Answers1

2

CreateObject("Excel.Application") throws replay error when ActiveX is not selected.

Make sure that the ActiveX add-in is selected, in the UFT add-in manager.

micstr
  • 5,080
  • 8
  • 48
  • 76
Jolly
  • 126
  • 6