Ask a Question

"OleObject" does not exist, TestComplete 12.2

SOLVED
andrewa
Contributor

"OleObject" does not exist, TestComplete 12.2

So we recently moved from TestComplete version 9 to 12.2. We have a number of tests that read and write data from Excel spreadsheets. I started to have problems with the JScript we use to access the sheets.

 

This is the line of code that keeps erroring out:

 

var app = Sys.OleObject("Excel.Application");

 

And the error message I get is: 

 

You are trying to call the "OleObject" method or property of the "Sys" object that does not exist.

 
I'm rather confused because when I type into the editor, it keeps giving me the autocomplete option for an OleObject.
 
I am running with a Windows 7 Enterprise operating system (64-bit) and I have Excel 2016 . I've tried running TestComplete as admin to see if it would solve the issue, but no difference.
 
Do I need to try some different code?
12 REPLIES 12
tristaanogre
Esteemed Contributor

Your code is correct and I've done a quick test of it myself here.

If you go in your project to the Object Browser and click on the Sys node there, make sure that the OleObject property is present.  If so, click on the Params button and enter in Excel.Application there.  Make sure that this works just to double check.

So, question... how are you calling that line?  Are you executing it directly or is that contained in some method that is stored elsewhere?  

The reason being is that the message being returned seems to indicate that the Sys object ITSELF doesn't exist.  It's not a problem with OleObject... which kinda means, to me, that you might be calling that JScript code in a different context where the Sys object is not present.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

In the object browser, I'm not even seeing an OleObject under the Sys node. It's really odd. (see the attached screenshot)

 

One of my Keyword tests calls the JScript code.

 

Honestly, I'm taking over maintaining the code from someone else, so there's quite a few things I don't quite understand. One of the issues is that our JScript code is probably pretty bloated. I might be missing something that runs and alters the state of things.

 

Also, the error vanished after I made this post, and I started getting a 'The remote server machine does not exist or is unavailable' while trying to access the excel file on a local drive.

tristaanogre
Esteemed Contributor

In the screenshot of your object browser, if you click on the link to show advanced view, you should see the OleObject.  

 

As for the rest of it... it's almost like you're stepping on some memory somewhere... any idea what the overall memory usage is at that point in your tests?


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

As for the "remote server" message, that usually indicates that, for some reason, the service for Excel.Application is unresponsive.  It doesn't have anything to do with the file location.

Double check a couple of things.  Make sure, in your task manager, that you don't have an instance of Excel open anywhere.  It could be running but not visible (calling the OleObject will do that).


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

Ah, I can see the OleObject in the advanced view.

 

As for memory issues, it seems to stay around 50% of memory usage for the test.

 

I noticed when I was debugging through the script it seemed to work. Perhaps I need some sort of delay after getting the OleObject? It could be moving so fast it doesn't load up correctly.

tristaanogre
Esteemed Contributor

A delay SHOULDN'T be necessary.

Question: Which version of MS Office do you have installed, 32 bit or 64 bit? I wonder if you may be running into a problem there since TestComplete is a 32-bit application.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

Looks like it's the 32-bit version. Microsoft Excel 2016 MSO (16.0.4456.1003).

 

It all seems so odd to me. Would JScript proceed if the app hadn't loaded into memory yet?

tristaanogre
Esteemed Contributor

Not sure... the variable assignment is assigning to a property, not necessarily calling a method that returns.  So... it could be that you do need some sort of delay.

 

What I would do is add

 

Sys.WaitProcess('Excel', 10000)

I did a quick smoke test of this and, yes, there IS a bit of a delay before the application is running.  Give this a try and see if this helps.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

That piece of code seemed to clear up most of the errors I had when trying to open up an Excel file.  The intermittent OleObject errors have come back. I'm guessing something with how my machine is configured might be causing this issue.

cancel
Showing results for 
Search instead for 
Did you mean: