cancel
Showing results for 
Search instead for 
Did you mean: 

Latest Excel VBO: 'Could not run the object because one of the code stages has a compile error, use Check for Errors for a list of problems'

john.hammond
Level 6

Morning all.

When trying to run pages from within the latest Excel object (link - MS Excel VBO), I'm presented with the following error:

'Could not run the object because one of the code stages has a compile error, use Check for Errors for a list of problems'

Upon investigating the Code stage, no such errors seem to exist. I've searched previous posts for this and it was suggested that a missing DLL could be the cause, but from the documentation, it doesn't appear as if this VBO requires any additional files. These are the listed dll's established:

28902.png
However, when checking for errors within the Object itself, there is an error related to the compiling:
28903.pngI don't know enough about the code for this particular action, and although c isn't declared, I'm assuming this particular 'c' isn't referring to a filepath, rather a data item that hasn't been declared. 

Am I missing something here? Do I need to amend the code for the 'Set Value of Cells in Range' object? Or just remove it entirely? Our team isn't using it, but I'm loathe to remove potential future functionality. 



------------------------------
John Hammond
------------------------------
1 BEST ANSWER

Best Answers

On the first line of code, add a coma after range and type c. Someone forgot to explicitly declare c and that's why you are finding that error. 

It should look like this:

Dim ws, range, c As Object


Try it and let me know if it works 😉



------------------------------
Ramón Requena López
RPA Developer
Magenta Telekom
------------------------------

View answer in original post

8 REPLIES 8

On the first line of code, add a coma after range and type c. Someone forgot to explicitly declare c and that's why you are finding that error. 

It should look like this:

Dim ws, range, c As Object


Try it and let me know if it works 😉



------------------------------
Ramón Requena López
RPA Developer
Magenta Telekom
------------------------------

Thanks Ramon, that worked a treat! I'll leave some feedback on the DX page - surprised that this hasn't been found sooner!

------------------------------
John Hammond
------------------------------

Cheers John, glad I could help 😉

------------------------------
Ramón Requena López
RPA Developer
Magenta Telekom
------------------------------

Hi @john.hammond,

That's an interesting find. By chance, did anyone add the line Option Infer Off to the VBO code anywhere? The reason I ask is that with a For Each...Next loop, as in that Excel code, the data type of the element (in this case 'c') is implicitly inferred based on the type of the objects contained in the collection that's being iterated over. Based on Microsoft's documentation, this should only result in an error if the VB feature Option Infer is specifically disabled - as shown above. The default, is for Option Infer to always be on. You can read more about it here if you're interested.

When I test the latest Excel VBO, and specifically that function, I don't get receive any compiler or runtime errors and the action executes as expected. Having said that, we'll make an update to the code to explicitly define the data type of that variable.

What version of Blue Prism and the .NET Framework are you running? I want to make sure we test the VBO on something as close to your specific environment as possible to see if there's some condition there that might be contributing to this?

Cheers,

------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------

Hi Eric,

There was a .NET compiler update from v6.8 onwards. It could be the reason behind the discrepency.

------------------------------
Bruce Liu
Senior Product Consultant, Professional Services
Blue Prism
Australia/Sydney
------------------------------

Hi @Bruce Liu,

Yes, that could be. That's why I want to understand what version of BP and .NET John's using.

Cheers,


------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------

Hey Chris, I am aware that's a feature in VBA since a couple of years, wasn't sure about VB tho (I know both are pretty similar, but I know my bearings better around VBA). 

Dunno about John's case, but we are in 6.4.2 and, as Bruce mentioned, implicit declaration is not working on VB code there either.

------------------------------
Ramón Requena López
RPA Developer
Magenta Telekom
------------------------------

Hi Eric. Apologies for the delay in getting back to you, had a long bank holiday weekend here in the UK!

I'm running Blue Prism v6.6. Looking at the registry, it looks like the machine in question is running .NET 4.0.

------------------------------
John Hammond
------------------------------