Question

I'm attempting to use office interop to interact with Excel on a remote machine. The simplest-seeming way I found to do this was to use the Microsoft.VisualBasic.Interaction.CreateObject method, which is documented here. In my case, the call made to it is:

var excelApp = (Application)Interaction.CreateObject("Excel.Application", machineName);

However, this isn't fully working as expected. The results I'm getting:

  • When the machineName is the local machine that I'm running the code on, this works as expected.
  • When the machineName is a remote machine, an instance of Excel actually is started on the machine, but the CreateObject call fails with exception:

System.Exception: The remote server machine does not exist or is unavailable.

Googling this message doesn't reveal much of use, the results seem to all be people with different symptoms.

I don't really have any leads on what's causing this. I noticed that the method documentation page I linked previously rather cryptically states:

Refer to COM documentation (see Microsoft Developer Network) for additional information on making an application accessible on a remote networked computer. You may need to add a registry key for your application.

But I've yet to find that documentation.

Any suggestions for what could be the problem here? Or, failing that, a different way of achieving the same thing? Due to my situation, remote interop like this is a firm requirement- using Excel on a local machine to access a remote file is not sufficient.

Additionally, I would very much like to avoid a solution that requires a service or anything similar to be running on the Excel client machine, which as I understand it would be necessary if I wanted to use Activator.CreateInstance with a UrlAttribute.

Was it helpful?

Solution

The problem was a DCOM configuration issue. All the appropriate permissions were set, but the application was not configured to run as the interactive user. I suspect that this problem is relatively uniquely identified by the combination of being able to launch the process but not being able to connect to it afterwards.

The setting for this can be found in Component Services (dcomcnfg), under: Component Services > Computers > My Computer > DCOM Config > Microsoft Excel Application. Right click this, select 'Properties', and configuration for which user account to run under is found on the 'Identity' tab.

An additional problem that I found along the way was that 'Microsoft Excel Application' was not initially listed in Component services, due to having 32-bit Excel on 64-bit Windows.

A solution for this, found here, was to run the 32-bit version of mmc (which can be done from the command line by starting with argument -32) and use the Component Services snap-in

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top