MS HPC Pack 2019: Excel COM jobs on compute nodes

Alberto Garcia Fernandez 26 Reputation points
2021-02-17T19:51:32.243+00:00

Hi all,

We write to you because we have a type of job in our WS2019 cluster that is not running properly. We wanted to ask you if you have any experience with this type of jobs that may help us.

The job in question is a call to a COM excel component in order to retrieve data from an excel sheet. We have installed MS Office 365 on the compute nodes, and the job in question could be summarised by the following line:

powershell -command "$filepath='\shared\temp\test.xlsx';get-item $filepath;$Excel = New-Object -ComObject Excel.Application;$Workbook=$Excel.Workbooks.Open($filepath);$Workbook.Sheets(1).Cells(1,1).Value2;$Excel.Quit();"

If we login manually on the compute nodes and we run the line, we successfully get the contents of the excel file.

If we try to run the line on a HPC Pack job, it fails. We obtain two kinds of error messages. Please find them below:

ERROR 1:
Directory: \shared\Temp

Mode LastWriteTime Length Name


-a---- 2/17/2021 6:20 PM 10278 test_ag_3.xlsx
Microsoft Excel cannot access the file '\shared\Temp\test.xlsx'. There are several
possible reasons:
The file name or path does not exist.
The file is being used by another program.
The workbook you are trying to save has the same name as a currently open workbook.
At line:1 char:139

  • ... Excel.Application;$Workbook=$Excel.Workbooks.Open($filepath);$Workbo ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : OperationStopped: (:) [], COMException
  • FullyQualifiedErrorId : System.Runtime.InteropServices.COMException

You cannot call a method on a null-valued expression.
At line:1 char:182

  • ... rkbooks.Open($filepath);$Workbook.Sheets(1).Cells(1,1).Value2;$Excel. ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : InvalidOperation: (:) [], RuntimeException
  • FullyQualifiedErrorId : InvokeMethodOnNull

ERROR 2:

Directory: \\shared\temp

Mode LastWriteTime Length Name


-a---- 2/17/2021 8:12 AM 10519 test.xlsx
New-Object : Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed
due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005
(CO_E_SERVER_EXEC_FAILURE)).
At line:1 char:94

  • ... em $filepath;$Excel = New-Object -ComObject Excel.Application;$Workbo ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : ResourceUnavailable: (:) [New-Object], COMException
  • FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand

You cannot call a method on a null-valued expression.
At line:1 char:134

  • ... Excel.Application;$Workbook=$Excel.Workbooks.Open($filepath);$Workbo ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : InvalidOperation: (:) [], RuntimeException
  • FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:1 char:177

  • ... rkbooks.Open($filepath);$Workbook.Sheets(1).Cells(1,1).Value2;$Excel. ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : InvalidOperation: (:) [], RuntimeException
  • FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:1 char:215

  • ... .Open($filepath);$Workbook.Sheets(1).Cells(1,1).Value2;$Excel.Quit();
  • ~~~~~~~~~~~~~
  • CategoryInfo : InvalidOperation: (:) [], RuntimeException
  • FullyQualifiedErrorId : InvokeMethodOnNull

Could you please help us out here? Do you have any insight on this type of jobs based on Office and COM?

Best Regards,
Alberto

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
8,259 questions
{count} votes

Accepted answer
  1. prmanhas-MSFT 17,906 Reputation points Microsoft Employee
    2021-02-23T13:23:22.227+00:00

    @Alberto Garcia Fernandez Apologies for the delay in response and all the inconvenience caused because of the issue.

    I reached out to our internal team and I guess you have reached out to internal team as well so sharing the same with community:

    The problem could be due to the requirement for Excel to run under an interactive user session. You may have a RDP session of the RunAs user on the compute nodes and then set the job environment HPC_ATTATCHTOSESSION to True to ensure the Excel process to run in a user session. You may choose HPC_CREATECONSOLE, there are additional node configurations needed as described here. Please also check this link for usage comparison among HPC_CREATECONSOLE, HPC_ATTACHTOCONSOLE and HPC_ATTATCHTOSESSION.

    Hope it helps!!!

    Please "Accept as Answer" if it helped so it can help others in community looking for help on similar topics.

    1 person found this answer helpful.
    0 comments No comments

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.