Excel stopped working, error 2147417851

Hi,

I’ve inherited an application that was running on Xojo Ancient ™ and Windows Double Ancient ™ that’s been moved and recompiled to a new Windows machine with new Office. Now when the application runs as my user (creates a web interface, populates Excel for download) it works fine. When it runs as a service (as it’s supposed to as a web thing) it returns -2147417851 as an excel error message. I don’t know enough about Xojo and office to troubleshoot, may I have help please?

Is Xojo supposed to work as “web thing”? How does the code look like or does the error show up before you do code? Have you Goggled the error?

I remember have this error, but not with xojo.

I resolve it with grants the right privilege and verify the files.
In my case, the software in cause try to access a file that not exist, and throw this error

(Sorry for my bad English :sweat_smile:)

Thanks Thibault. I’ve confirmed that the file exists, but it looks like the Excel plugin is failing. I’ve confirmed this with the following code:

Dim excel As New ExcelApplication
dim StepMe as String
StepMe = "1"  
...  
  StepMe = StepMe + "3"  
  System.DebugLog("Step 3")  
  StepMe = StepMe + "." + excel.Version + "."  
...
Exception err As OLEException
  System.DebugLog("Failed in creating the Excel " + err.Message + "|(" + StepMe + ")")  

It responds with
Failed in creating the Excel Unknown error: -2147418111, (Failed on “Version”)|(123)

Thanks Beatrix,

Yup, I run the compiled XOJO with “–secureport=#####” to make it run as a self contained web app w’ certificates etc. I’ve cut it down to the following debug code to replicate the error:

Dim excel As New ExcelApplication
dim StepMe as String
StepMe = “1”
…
StepMe = StepMe + “3”
System.DebugLog(“Step 3”)
StepMe = StepMe + “.” + excel.Version + “.”
…
Exception err As OLEException
System.DebugLog("Failed in creating the Excel " + err.Message + “|(” + StepMe + “)”)

It responds with
Failed in creating the Excel Unknown error: -2147418111, (Failed on “Version”)|(123)

As stated, when I start the application when logged in as myself, it works fine. When it starts as a windows service, it fails with the above. I’ve had someone who knows more about windows permissions than me look at it, and they are also stumped. I run the version in the same directory as the service-run version.

I’ve tried Googling the error, a lot of it comes back with permissions (which don’t look to be the issue) and others come back with OLE versions. I would think that having the above fail at the excel object step it’s an Excel issue rather than permissions?

Do you have access to the old machine? If so, what does the service RunAs compared with your new machines service? Is Excel installed for all users if its running as a different user?

You might want to check this forum thread:
https://forum.xojo.com/t/excel-automation-in-console-application/66744

Xojo Web is a console application.

Thanks Julian. Unfortunately no, the old machine was turned off and removed.

Thanks Georgios. Interesting, I did not know that about the console application component. I’ll see if that addresses the issue.

What OS and version is the new machine running and what version of Excel are you using?

Windows Server 2012R2
Excel 2016

I’m quite curious why it’s working when I run it from the command prompt, but not when the service runs it. I mean, that does sound like permissions - but it’s failing on excel.Version. That indicates to me it’s an Excel plugin or OLE issue; but why would the service execution have that and not my account?

Who is the service set to run as ? Your user?

Yes. We’ve tried it as Local Account and we’ve tried it running as my user.


Further debugging, I moved my step up to where I Dim excel:

' DEBUGGING
dim StepMe as String
StepMe = "0"  
System.DebugLog("Step 0")  

Dim excel As New ExcelApplication
StepMe = "a"  
System.DebugLog("Step a")  

And the first failure I get is

[#] Step 0
[#] Failed in creating the Excel Unknown error: -2147417846|(0)

So is there a likelihood the service is looking at a difference place for the plugin compared to my user? Referencing Georgios’ suggestion I am still logged in when this service is running, so it doesn’t look like the console is the issue.

Is there anything pertinent in the error log in windows?

Not that I can see.

Sorry not debuglog, but event viewer, windows logs, application

Ah, sorry, not a Windows guy.

Application

image

Also, that’s a different error code ?!

-2147417846 is 0x8001010A or RPC_E_SERVERCALL_RETRYLATER

Have you:

Make sure that you have unchecked the "Ignore other applications" option from the Excel settings Options (Advanced / General).

This is all google foo by the way, its been a long time since I’ve touched OLE or excel and I dont have office 2016 to install to test this :frowning:

Yup.

It is under my account though. I wonder if the service account needs that as well, and how we’d do that.

(a lot of the above is confirming my own Google-fu, so it’s gratifying to see I’ve approached it the right way :wink: )

1 Like

Addition: I’ve added in a New WordApplication step and that has worked.:

' DEBUGGING
dim StepMe as String
StepMe = "0"  
System.DebugLog("Step 0")  
Dim word as New WordApplication
StepMe = "z"
System.DebugLog("Step z")
Dim excel As New ExcelApplication
StepMe = "a"  
System.DebugLog("Step a")  

Tried a reboot? :smiley:
Downloading iso’s of Windows Server 2012R2 and Office 2016 now.