Batch task can't use Excel library

Fang Ji 21 Reputation points
2021-01-05T10:35:57.827+00:00

Hi,

I have a pool, which has a node, which is Windows with Office 365, and Office 365 is already activated. I have a command invoking a C++ library, in which the Excel instance is created by code:

new QAxObject("Excel.Application")

then the C++ library uses this Excel instance to invoke Excel related functions.

This command and the C++ library works quite fine when I log into the Windows and run the command. But when I create a batch task using this command, the code always fails at

new QAxObject("Excel.Application")

says QAxBase::setControl: requested control Excel.Application could not be instantiated

Also there is another error when invoking SetProcessDpiAwareness method, says COM error 0xffffffff80070005 (Unknown error 0x0ffffffff80070005),

They all seems COM related. The errors don't happen when you log into Windows and run command.

So is there limitation in batch command invoking COM component? What is the difference running with batch command and running in Windows with UI? Is it because there is some service not started when using batch command?

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,585 questions
0 comments No comments
{count} votes

Accepted answer
  1. RLWA32 45,236 Reputation points
    2021-01-05T10:49:13.133+00:00

    Automation of Microsoft Office Applications from a non-interactive session are discouraged by Microsoft and are not supported. If by batch command you mean using the task scheduler to run a task without a user being logged on then that is an unsupported environment.

    considerations-for-server-side-automation-of-office

    "Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment."


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.