79098996

Date: 2024-10-17 16:18:07
Score: 1
Natty:
Report link

For anyone who has this issue in the future: it is possible to run Interop with a non-interactive task. I was able to make it work tweaking CSOM settings. Here are the steps:

  1. Open dcomcnfg Press Win + R to open the Run dialog. Type dcomcnfg and press Enter. This will open the Component Services window.
  2. Navigate to Microsoft Excel Application In the Component Services window, expand the following: Component Services → Computers → My Computer → DCOM Config. Scroll down the list until you find Microsoft Excel Application. The entries are listed alphabetically, so it will be towards the middle.
  3. Configure DCOM Properties for Excel Right-click on Microsoft Excel Application and choose Properties.

A new window will open. Now follow the steps below to configure permissions:

General Tab:

Ensure that Authentication Level is set to Default. Security Tab:

Under Launch and Activation Permissions, click Customize and then Edit.

Add the user account that runs the Task Scheduler job and grant it the following permissions:

Local Launch: Allow Remote Launch: (only if you plan to run Excel from another machine) Local Activation: Allow Remote Activation: (only if running from another machine) Under Access Permissions, click Customize and then Edit.

Add the user or service account running the task and give it access permissions as needed. Identity Tab:

Here, choose how you want Excel to run. You have three options: The interactive user: This runs Excel only when a user is logged in. The launching user: This runs Excel using the user who launches the task. This user: You can specify a specific user account (provide username and password) to run Excel. If you want Excel to run as a background task, choose This user and provide the credentials of a user that has the necessary permissions.

  1. Restart the DCOM Service Once you've configured DCOM for Excel, you might need to restart the DCOM service. You can do this by restarting the machine or using the following steps:

Open Services (press Win + R, type services.msc, and press Enter). Find DCOM Server Process Launcher. Right-click and select Restart.

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Bruno Vilela